Submission
Status:
PP--PPP-----PPP----P
Subtask/Task Score:
45/100
Score: 45
User: kf._.exe
Problemset: Othello
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-17 21:02:24
#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
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)) return false;
if(s[n][m] == c) return true;
if(_update(n+a, m+b , a, b, c)) s[n][m] = c ;
return false;
}
void update(int n,int m,char c){
_update(n+1, m, 1, 0, c); // check down;
_update(n-1, m, -1, 0, c); // check up;
_update(n, m+1, 0, 1, c); // check right;
_update(n, m-1, 0, -1, c); // check left;
_update(n+1, m+1, 1, 1, c);// check down diagonal;
_update(n-1, m-1, -1, -1, c);// check up diagonal;
}
void solve(){
// input
for(string &x:s) cin >> x;
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;
update(n,m,c);
c = (c == 'B')? 'W' : 'B';
}
// count
int 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;
}