Submission
Status:
PPPPPP-PPPPP-P----PP
Subtask/Task Score:
70/100
Score: 70
User: CiCiiAlWh
Problemset: Othello
Language: cpp
Time: 0.003 second
Submitted On: 2025-09-28 14:56:00
#include<bits/stdc++.h>
using namespace std;
int dr[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dc[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
bool inside(int r, int c) {
return r >= 0 && r < 8 && c >= 0 && c < 8;
}
int main() {
char board[8][8];
string s;
for (int i = 0; i < 8; i++) {
cin >> s;
for (int j = 0; j < 8; j++) {
board[i][j] = s[j];
}
}
int r, c, turn = 0;
auto opp = [&](char ch) { return ch == 'B' ? 'W' : 'B'; };
while (cin >> r >> c) {
if (r == -1 && c == -1) break;
char cur = (turn % 2 == 0 ? 'B' : 'W');
char other = opp(cur);
board[r][c] = cur;
for (int d = 0; d < 8; d++) {
int nr = r + dr[d], nc = c + dc[d];
vector<pair<int, int>> path;
while (inside(nr, nc) && board[nr][nc] == other) {
path.push_back({nr, nc});
nr += dr[d];
nc += dc[d];
}
if (inside(nr, nc) && board[nr][nc] == cur && !path.empty()) {
for (auto &p : path) {
board[p.first][p.second] = cur;
}
}
}
bool full = true;
for (int i = 0; i < 8 && full; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j] == '_') full = false;
}
}
if (full) break;
turn++;
}
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) cout << board[i][j];
cout << "\n";
}
int b = 0, w = 0;
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
if (board[i][j] == 'B') b++;
else if (board[i][j] == 'W') w++;
}
}
if (b > w) cout << "black wins\n";
else if (w > b) cout << "white wins\n";
else cout << "draw\n";
return 0;
}