Submission

Status:

PPPPPP-PPPPP-P----PP

Subtask/Task Score:

70/100

Score: 70

User: wleo.lwo

Problemset: Othello

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-07 14:43:03

#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {

vector<string> mp(8);


for (int i = 0; i < 8; i++) {
cin >> mp[i];
}



int dx[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

char color = 'B';


while (true) {

int x, y;
cin >> x >> y;


if (x == -1 && y == -1) {
break;
}


mp[x][y] = color;



for (int d = 0; d < 8; d++) {

int nx = x + dx[d];
int ny = y + dy[d];



while (nx >= 0 && nx < 8 &&
ny >= 0 && ny < 8) {


if (mp[nx][ny] == '_') {
break;
}



if (mp[nx][ny] == color) {

int fx = x + dx[d];
int fy = y + dy[d];


while (fx != nx || fy != ny) {

mp[fx][fy] = color;

fx += dx[d];
fy += dy[d];
}

break;
}



nx += dx[d];
ny += dy[d];
}
}



bool full = true;

for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {

if (mp[i][j] == '_') {
full = false;
}
}
}



if (full == true) {
break;
}



if (color == 'B') {
color = 'W';
}
else {
color = 'B';
}
}




int black = 0;
int white = 0;

for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {

if (mp[i][j] == 'B') {
black++;
}

if (mp[i][j] == 'W') {
white++;
}
}
}



for (int i = 0; i < 8; i++) {
cout << mp[i] << '\n';
}



if (black > white) {
cout << "black wins";
}
else if (white > black) {
cout << "white wins";
}
else {
cout << "draw";
}


return 0;
}