Submission
Status:
PPPPPP-PPPPP-P----PP
Subtask/Task Score:
70/100
Score: 70
User: Sunsblad
Problemset: Othello
Language: cpp
Time: 0.003 second
Submitted On: 2026-10-13 20:11:34
#include<iostream>
#include<vector>
using namespace std;
int main(){
int counter = 0;
vector<string> box(8,string(8,' '));
for(int i = 0; i < 8; i++){
for(int j = 0; j < 8; j++){
cin>>box[i][j];
if(box[i][j] == 'W' or box[i][j] == 'B'){
counter++;
}
}
}
bool black = true;
while(true){
if(counter >= 64)break;
int row, collum;
char curr;
cin>>row>>collum;
counter++;
if(row == -1 and collum == -1)break;
if(black){
curr = 'B';
black = false;
}else{
curr = 'W';
black = true;
}
box[row][collum] = curr;
int tmprow = row;
int tmpcollum = collum;
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, 1,-1, 0, 1,-1};
for(int i = 0; i < 8; i++){
row = tmprow;
collum = tmpcollum;
int movex = dx[i];
int movey = dy[i];
int countmove = 0;
while(row + movex >= 0 && row + movex < 8 && collum + movey >= 0 && collum + movey < 8){
countmove++;
row += movex;
collum += movey;
if(box[row][collum] == '_'){break;}//cout<<"break"<<movex<<' '<<movey<<'\n';break;}
if(box[row][collum] == curr){
for(int j = 0; j < countmove; j++){
box[row][collum] = curr;
//cout<<row<<' '<<collum<<' ';
row -= movex;
collum -= movey;
}
break;
}
}
}
}
int black1 =0, white =0;
for(int i = 0; i < 8; i++){
for(int j = 0; j < 8; j++){
cout<<box[i][j];
if(box[i][j] == 'W')white++;
if(box[i][j] == 'B')black1++;
}
cout<<'\n';
}
if(black1 > white){
cout<<"black wins";
}else if(white > black1){
cout<<"white wins";
}else cout<<"draw";
}