Submission
Status:
PPPP-P-PPPPP-P----PP
Subtask/Task Score:
65/100
Score: 65
User: kf._.exe
Problemset: Othello
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-17 22:21:13
#include <algorithm>
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define dbg(x) cout << #x << " = " << x << '\n';
#define int long long
#define dd double
#define ld long double
int cntw = 0,cntb = 0;
vector<string> s(8,string(8,'_'));
#define chk(n,m) (n >= 8 || n < 0 || m >= 8 || m < 0)
bool _update(int n,int m,int a,int b,char c){
if(chk(n, m) || s[n][m] == '_') return false;
if(s[n][m] == c) return true;
if(_update(n+a, m+b , a, b, c)) {
s[n][m] = c;
return true;
}
#ifdef ONPC
for(auto &x:s) cout << x << endl;
#endif
return false;
}
void cnt(){
cntw = cntb = 0;
for(string &x:s){
for(char &y:x){
if(y == 'W') cntw++;
if(y == 'B') cntb++;
}
}
}
void update(int n,int m,char c){
_update(n+1, m, 1, 0, c);
_update(n-1, m, -1, 0, c);
_update(n, m+1, 0, 1, c);
_update(n, m-1, 0, -1, c);
_update(n+1, m+1, 1, 1, c);
_update(n-1, m-1, -1, -1, c);
_update(n+1, m-1, 1, -1 ,c);
_update(n-1, m+1, -1, 1 ,c);
}
void solve(){
// input
for(string &x:s) {
cin >> x;
for(char &y:x){
if(y == 'W') cntw++;
if(y == 'B') cntb++;
}
}
char c='B';
//logic
while(1){
int n,m;cin >> n >> m;
if(n==-1&&m==-1) break;
//if(s[n][m] != '_'){
// c = (c == 'B')? 'W' : 'B';
// continue;
//}
s[n][m] = c;
cnt();
if(cntb+cntw == 64) break;
update(n,m,c);
c = (c == 'B')? 'W' : 'B';
}
// count
cntw = 0,cntb = 0;
for(string &x:s){
for(char &y:x){
if(y == 'W') ++cntw;
else if(y == 'B') ++cntb;
}
cout << x << endl;
}
if(cntw > cntb ) cout << "white wins";
else if(cntw < cntb) cout << "black wins";
else cout << "draw";
cout << endl;
}
int32_t main(){
fastio;
int T = 1;
//cin >> T
while(T--) solve();
return 0;
}