Submission
Status:
P---P--------------P
Subtask/Task Score:
15/100
Score: 15
User: mister_o_hater_no1
Problemset: Othello
Language: cpp
Time: 0.003 second
Submitted On: 2025-10-17 01:25:02
#include <bits/stdc++.h>
using namespace std;
vector<string> othello;
void print(){
for (int i= 0; i< 8; ++i) {
cout<< othello[i]<< '\n';
}
}
void right(int y, int x, char c) {
for (int i= x+ 1; i< 8; ++i) {
if (othello[y][i]== '_') break;
else if (othello[y][i]== c) {
for (int j= i- 1; j> x; --j) {
othello[y][j]= c;
}
break;
}
}
}
void left(int y, int x, char c) {
for (int i= x- 1; i>= 0; --i) {
if (othello[y][i]== '_') break;
else if (othello[y][i]== c) {
for (int j= i+ 1; j< x; ++j) {
othello[y][j]= c;
}
break;
}
}
}
void down(int y, int x, char c) {
for (int i= y+ 1; i< 8; ++i) {
if (othello[i][x]== '_') break;
else if (othello[i][x]== c) {
for (int j= i- 1; j> y; --j) {
othello[j][x]= c;
}
break;
}
}
}
void up(int y, int x, char c) {
for (int i= y- 1; i>= 0; --i) {
if (othello[i][x]== '_') break;
else if (othello[i][x]== c) {
for (int j= i+ 1; j< y; ++j) {
othello[j][x]= c;
}
break;
}
}
}
void up_right(int y, int x, char c) {
int i= y- 1;
int j= x+ 1;
while (i>= 0 && j< 8) {
if (othello[i][j]== '_') break;
else if (othello[i][j]== c) {
for (int k= i+ 1, o= j- 1; k< y && o> x; ++k, --o) {
othello[k][o]= c;
}
break;
}
--i; ++j;
}
}
void up_left(int y, int x, char c) {
int i= y- 1;
int j= x- 1;
while (i>= 0 && j>= 0) {
if (othello[i][j]== '_') break;
else if (othello[i][j]== c) {
for (int k= i+ 1, o= j+ 1; k< y && o< x; ++k, ++o) {
othello[k][o]= c;
}
break;
}
--i; --j;
}
}
void down_right(int y, int x, char c) {
int i= y+ 1;
int j= x+ 1;
while (i< 8 && j< 8) {
if (othello[i][j]== '_') break;
else if (othello[i][j]== c) {
for (int k= i- 1, o= j- 1; k> y && o> x; --k, --o) {
othello[k][o]= c;
}
break;
}
++i; ++j;
}
}
void down_left(int y, int x, char c) {
int i= y+ 1;
int j= x- 1;
while (i< 8 && j>= 0) {
if (othello[i][j]== '_') break;
else if (othello[i][j]== c) {
for (int k= i- 1, o= j+ 1; k> y && o< x; --k, ++o) {
othello[k][o]= c;
}
break;
}
++i; --j;
}
}
void place(int y, int x, char c) {
othello[y][x]= c;
}
void winner() {
int black= 0, white= 0;
for (int i= 0; i< 8; ++i) {
for (int j= 0; j< 8; ++j) {
if (othello[i][j]== 'B') black++;
else if (othello[i][j]== 'W') white++;
}
}
if (black> white) cout<< "black wins";
else if (white> black) cout<< "white wins";
else cout<< "draw";
}
bool full() {
bool full_check= true;
for (auto &row: othello) {
if (row.find('_') != string::npos) full_check = false;
}
return full;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(0);
string temp; int turn= 1;
for (int i= 0; i< 8; ++i) {
cin>> temp;
othello.push_back(temp);
}
int y, x;
while (cin>> y>> x) {
if (y== -1 && x== -1) break;
if (turn% 2!= 0) {
place(y, x, 'B');
right(y, x, 'B');
left(y, x, 'B');
up(y, x, 'B');
down(y, x, 'B');
up_right(y, x, 'B');
up_left(y, x, 'B');
down_right(y, x, 'B');
down_left(y, x, 'B');
}
else {
place(y, x, 'W');
right(y, x, 'W');
left(y, x, 'W');
up(y, x, 'W');
down(y, x, 'W');
up_right(y, x, 'W');
up_left(y, x, 'W');
down_right(y, x, 'W');
down_left(y, x, 'W');
}
if (full) break;
turn++;
}
print();
winner();
return 0;
}