Submission
Status:
PPPPPP-PPPPP-P----PP
Subtask/Task Score:
70/100
Score: 70
User: colo39
Problemset: Othello
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-02 15:17:05
#include <bits/stdc++.h>
using namespace std;
int dx[] = {0,0,1,-1,-1,1,1,-1};
int dy[] = {1,-1,0,0,-1,1,-1,1};
int table[10][10];
int stx, sty; int available = 64;
void sol(int sti, int stj, int direction, int sum, int c) {
if (sti < 1 || stj < 1 || sti > 8 || stj > 8) return;
if (direction != -1) {
if ((table[sti][stj] == c)) {
int i = stx + dx[direction];
int j = sty + dy[direction];
while (i != sti || j != stj) {
table[i][j] = c;
i += dx[direction];
j += dy[direction];
}
return;
} else if (table[sti][stj] == 0) return;
else sum++;
}
if (direction == -1) {
for (int i = 0;i < 8;i++) {
sol(sti+dx[i],stj+dy[i],i,sum,c);
}
} else {
sol(sti+dx[direction],stj+dy[direction],direction,sum,c);
}
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
for (int i = 1;i <= 8;i++) {
for (int j = 1;j <= 8;j++) {
char c;
cin >> c;
if (c == 'W') {table[i][j] = 1;available--;}
else if (c == 'B') {table[i][j] = 2;available--;}
}
}
int turn = 2;
while (1) {
if (available == 0) break;
int x,y;
cin >> x >> y;
if (x == -1 && y == -1) break;
x++;
y++;
if (table[x][y] != turn) available--;
table[x][y] = turn;
stx =x;
sty = y;
sol(x,y,-1,0,turn);
if (turn == 2) turn = 1;
else turn = 2;
}
int w = 0, b = 0;
for (int i = 1;i <= 8;i++) {
for (int j = 1;j <= 8;j++) {
if (table[i][j] == 0) cout << "_";
else if (table[i][j] == 1) {cout << "W";w++;}
else {cout << "B";b++;}
}
cout << endl;
}
if (w == b) cout << "draw";
else if (w > b) cout << "white wins";
else cout << "black wins";
}