Submission
Status:
PPPPPPPPPPPPPPP-P-PP
Subtask/Task Score:
90/100
Score: 90
User: matcherbrainner
Problemset: Othello
Language: cpp
Time: 0.004 second
Submitted On: 2026-11-28 21:10:31
#include<bits/stdc++.h>
using namespace std;
char a[8][8];
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;
}
void play(int r,int c,char color){
if(!inside(r,c)||a[r][c]!='_') return;
char opp;
if(color=='B') opp='W';
else opp='B';
a[r][c]=color;
for(int d=0;d<8;d++){
int x=r+dr[d];
int y=c+dc[d];
int cnt=0;
int rr[8],cc[8];
while(inside(x,y)&&a[x][y]==opp){
rr[cnt]=x;
cc[cnt]=y;
cnt++;
x+=dr[d];
y+=dc[d];
}
if(cnt>0&&inside(x,y)&&a[x][y]==color){
for(int i=0;i<cnt;i++){
a[rr[i]][cc[i]]=color;
}
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cin>>a[i][j];
}
}
char color='B';
int r,c;
while(cin>>r>>c){
if(r==-1&&c==-1) break;
play(r,c,color);
if(color=='B') color='W';
else color='B';
int full=1;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
if(a[i][j]=='_') full=0;
}
}
if(full) break;
}
int b=0,w=0;
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
cout<<a[i][j];
if(a[i][j]=='B') b++;
if(a[i][j]=='W') w++;
}
cout<<"\n";
}
if(b>w) cout<<"black wins\n";
else if(w>b) cout<<"white wins\n";
else cout<<"draw\n";
}