結果

提出番号 540
提出者 ndifix
言語 C++
提出日時 2017-07-24 01:27:33
問題名 (42)オセロ
結果 WA
点数 0%

テストケース

テストケース 結果 得点 実行時間 メモリ使用量
1 AC 100% 2ms 8336KB
2 AC 100% 5ms 8272KB
3 AC 100% 3ms 8256KB
4 WA 0% 3ms 8240KB
5 AC 100% 3ms 8256KB

ソースコード

#include <iostream>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

int main(){
	/*string file;
	cin >> file;
	file += "_in.txt";
	cout << file.c_str() << endl;
	ifstream in(file.c_str());*/
	vector<string> s;
	s.resize(8);

	for(int i=0; i<8; i++) cin>>s[i];
	int c;
	char t[3];
	cin >> c >> t;
	int t2[2];
	t2[0]=t[0]-'A';
	t2[1]=t[1]-'1';
	char my, op;
	if (c == 0){
		my = 'b';
		op = 'w';
	}
	if (c == 1){
		my = 'w';
		op = 'b';
	}
	int x, y;
	int v, w;
	int flag;
	for (int d = 0; d < 8; d++){
		if (d == 0){ x = 0; y = -1; }
		if (d == 1){ x = 1; }
		if (d == 2){ y = 0; }
		if (d == 3){ y = 1; }
		if (d == 4){ x = 0; }
		if (d == 5){ x = -1;}
		if (d == 6){ y = 0; }
		if (d == 7){ y = -1;}
		//cout << x << " " << y << endl;
		v = t2[0];
		w = t2[1];
		flag = 0;
		while (1){
			if (s[w][v] == my){ flag = 1; break; }
			if (0 <= v + x && v + x < 8 && 0 <= w + y && w + y < 8){
				v += x;
				w += y;
			}
			else break;
			
			//cout << v << " " << w << endl;
		}
		v = t2[0];
		w = t2[1];
		if (flag == 1){
			//cout << d << endl;
			while (s[w][v]!=my){
				v += x;
				w += y;
				s[w][v] = my;
				/*for (int k = 0; k < 8; k++) cout << s[k] << endl;
				cout << endl;*/
			}
		}
	}
	s[t2[1]][t2[0]] = my;

	for (int i = 0; i < 8; i++) cout << s[i] << endl;

	//cin >> x;
	return 0;
}