結果

提出番号 904
提出者 data9824
言語 C++
提出日時 2017-08-01 15:40:03
問題名 (42)オセロ
結果 WA
点数 0%

テストケース

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

ソースコード

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

using namespace std;

int main() {
	vector<string> board(8);
	for (int i = 0; i < 8; ++i) {
		cin >> board[i];
	}
	int c;
	cin >> c;
	char color = (c == 0) ? 'b' : 'w';
	string position;
	cin >> position;
	int x0 = position[0] - 'A';
	int y0 = position[1] - '1';
	int dx[] = { -1, -1, 0, 1, 1, 1, 0, -1 };
	int dy[] = { 0, -1, -1, -1, 0, 1, 1, 1 };
	board[y0][x0] = color;
	for (int i = 0; i < 8; ++i) {
		vector<string> saved(board);
		bool skip = false;
		int x = x0 + dx[i];
		int y = y0 + dy[i];
		while (x >= 0 && x < 8 && y >= 0 && y < 8) {
			if (board[y][x] == '-') {
				board = saved;
				break;
			}
			else if (board[y][x] != color) {
				board[y][x] = color;
			}
			else {
				break;
			}
		}
	}
	for (int i = 0; i < 8; ++i) {
		cout << board[i] << endl;
	}
	return 0;
}