Submission
Status:
PPPPPP-PPPPP-P----PP
Subtask/Task Score:
70/100
Score: 70
User: eefirefire
Problemset: Othello
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-22 15:59:12
#include <bits/stdc++.h>
using namespace std;
void right(int R, int C, char turn, vector<string> &board)
{
for (int i = C + 1; i < 8; i++)
{
// cout << i << " ";
// cout << board[R][i] << "\n";
if (board[R][i] == turn)
{
for (int j = C + 1; j < i; j++)
{
board[R][j] = turn;
}
break;
}
else if (board[R][i] == '_')
{
break;
}
}
}
void left(int R, int C, char turn, vector<string> &board)
{
for (int i = C - 1; i >= 0; i--)
{
if (board[R][i] == turn)
{
for (int j = C - 1; j > i; j--)
{
board[R][j] = turn;
}
break;
}
else if (board[R][i] == '_')
{
break;
}
}
}
void up(int R, int C, char turn, vector<string> &board)
{
for (int i = R - 1; i >= 0; i--)
{
if (board[i][C] == turn)
{
for (int j = R - 1; j > i; j--)
{
board[j][C] = turn;
}
break;
}
else if (board[i][C] == '_')
{
break;
}
}
}
void down(int R, int C, char turn, vector<string> &board)
{
for (int i = R + 1; i < 8; i++)
{
if (board[i][C] == turn)
{
for (int j = R + 1; j < i; j++)
{
board[j][C] = turn;
}
break;
}
else if (board[i][C] == '_')
{
break;
}
}
}
void rightdown(int R, int C, char turn, vector<string> &board)
{
for (int i = R + 1, j = C + 1; i < 8 && j < 8; i++, j++)
{
if (board[i][j] == turn)
{
for (int x = R + 1, y = C + 1; x < i && y < j; x++, y++)
{
board[x][y] = turn;
}
break;
}
else if (board[i][j] == '_')
{
break;
}
}
}
void leftdown(int R, int C, char turn, vector<string> &board)
{
for (int i = R + 1, j = C - 1; i < 8 && j >= 0; i++, j--)
{
if (board[i][j] == turn)
{
for (int x = R + 1, y = C - 1; x < i && y > j; x++, y--)
{
board[x][y] = turn;
}
break;
}
else if (board[i][j] == '_')
{
break;
}
}
}
void leftup(int R, int C, char turn, vector<string> &board)
{
for (int i = R - 1, j = C - 1; i >= 0 && j >= 0; i--, j--)
{
if (board[i][j] == turn)
{
for (int x = R - 1, y = C - 1; x > i && y > j; x--, y--)
{
board[x][y] = turn;
}
break;
}
else if (board[i][j] == '_')
{
break;
}
}
}
void rightup(int R, int C, char turn, vector<string> &board)
{
for (int i = R - 1, j = C + 1; i >= 0 && j < 8; i--, j++)
{
if (board[i][j] == turn)
{
for (int x = R - 1, y = C + 1; x > i && y < j; x--, y++)
{
board[x][y] = turn;
}
break;
}
else if (board[i][j] == '_')
{
break;
}
}
}
int main()
{
vector<string> board;
int R, C;
for (int i = 0; i < 8; i++)
{
string temp;
cin >> temp;
board.push_back(temp);
}
char turn = 'B';
int black_count = 0;
int white_count = 0;
while (true)
{
cin >> R >> C;
if (R == -1 && C == -1)
{
break;
}
board[R][C] = turn;
right(R, C, turn, board);
left(R, C, turn, board);
down(R, C, turn, board);
up(R, C, turn, board);
rightup(R, C, turn, board);
rightdown(R, C, turn, board);
leftup(R, C, turn, board);
leftdown(R, C, turn, board);
if (turn == 'B')
{
turn = 'W';
}
else
{
turn = 'B';
}
// for (int i = 0; i < 8; i++)
// {
// for (int j = 0; j < 8; j++)
// {
// if (board[i][j] == 'B')
// {
// black_count++;
// // cout <<"black counted\n";
// }
// else if (board[i][j] == 'W')
// {
// // cout << "white counted\n";
// white_count++;
// }
// }
// cout << board[i] << "\n";
// }
// cout << "STOP RIGHT HERE\n";
bool temp = false;
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
if (board[i][j] == '_')
{
temp = true;
}
}
}
if(temp == false){
break;
}
}
for (int i = 0; i < 8; i++)
{
for (int j = 0; j < 8; j++)
{
if (board[i][j] == 'B')
{
black_count++;
// cout <<"black counted\n";
}
else if (board[i][j] == 'W')
{
// cout << "white counted\n";
white_count++;
}
}
cout << board[i] << "\n";
}
// cout << black_count;
// cout << "\n" << white_count;
if (black_count > white_count)
{
cout << "black wins";
}
else if (black_count < white_count)
{
cout << "white wins";
}
else
{
cout << "draw";
}
}
/*
________
________
________
________
___WWWB_
________
________
________
4 2
________
________
________
________
__BWWW__
_WBBB___
________
________
4 6
5 5
________
________
________
___B____
__BWWW__
________
________
________
5 3
________
________
________
________
__BWWW__
___B____
________
________
3 3
________
________
________
________
___WWW__
____B___
________
________
3 2
________
________
________
________
___WWW__
___B____
________
________
3 5
________
________
________
__B_____
___WWW__
________
________
________
5 4
________
________
________
____B___
___WWW__
________
________
________
5 2
BBBBBBBB
BWWWWWWB
BWWWWWWB
BWWWWWWB
BWWW_WWB
BWWWWWWB
BWWWWWWB
BBBBBBBB
4 4
*/