Submission
Status:
PPPPPP-PPPPP-P----PP
Subtask/Task Score:
70/100
Score: 70
User: Kidmaiok
Problemset: Othello
Language: cpp
Time: 0.005 second
Submitted On: 2026-10-15 15:43:02
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define space << ' '
#define nl << endl
bool up(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
y--;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool right(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
x++;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool left(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
x--;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool down(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
y++;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool up_right(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
y--;
x++;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool up_left(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
y--;
x--;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool down_right(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
y++;
x++;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
bool down_left(int x, int y,char board[][8], bool turn){
bool foundOpponent = false;
while(true){
y++;
x--;
if(x < 0 || y < 0 || x >= 8 || y >= 8){
return false;
}
if(board[y][x] == '_'){
return false;
}
if ((turn == 0 && board[y][x] == 'B') ||
(turn == 1 && board[y][x] == 'W')) {
return foundOpponent;
}
foundOpponent = true;
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
char table[8][8];
for(int i =0; i < 8; i++){
for(int j =0; j < 8; j++){
cin >> table[i][j];
}
}
vector<pair<int,int>> corr;
while (true) {
int a, b;
if (!(cin >> a >> b)) {
break;
}
if (a == -1 && b == -1) {
break;
}
corr.push_back({b, a});
}
for(int i =0; i < corr.size(); i++){
bool turn = i%2;
if (turn == 1) {
table[corr[i].second][corr[i].first] = 'W';
} else {
table[corr[i].second][corr[i].first] = 'B';
}
if(up(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j =1; corr[i].second - j >= 0; j++){
if(table[corr[i].second-j][corr[i].first] == 'B'){
break;
}else{
table[corr[i].second-j][corr[i].first] = 'B';
}
}
}else{
for(int j =1; corr[i].second - j >= 0; j++){
if(table[corr[i].second-j][corr[i].first] == 'W'){
break;
}else{
table[corr[i].second-j][corr[i].first] = 'W';
}
}
}
}
if(right(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j =1; corr[i].first + j < 8; j++){
if(table[corr[i].second][corr[i].first+j] == 'B'){
break;
}else{
table[corr[i].second][corr[i].first+j] = 'B';
}
}
}else{
for(int j =1; corr[i].first + j < 8; j++){
if(table[corr[i].second][corr[i].first+j] == 'W'){
break;
}else{
table[corr[i].second][corr[i].first+j] = 'W';
}
}
}
}
if(left(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j =1; corr[i].first - j >= 0; j++){
if(table[corr[i].second][corr[i].first-j] == 'B'){
break;
}else{
table[corr[i].second][corr[i].first-j] = 'B';
}
}
}else{
for(int j =1; corr[i].first - j >= 0; j++){
if(table[corr[i].second][corr[i].first-j] == 'W'){
break;
}else{
table[corr[i].second][corr[i].first-j] = 'W';
}
}
}
}
if(down(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j =1; corr[i].second + j < 8; j++){
if(table[corr[i].second+j][corr[i].first] == 'B'){
break;
}else{
table[corr[i].second+j][corr[i].first] = 'B';
}
}
}else{
for(int j =1; corr[i].second + j < 8; j++){
if(table[corr[i].second+j][corr[i].first] == 'W'){
break;
}else{
table[corr[i].second+j][corr[i].first] = 'W';
}
}
}
}
if(up_right(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j = 1;corr[i].second - j >= 0 && corr[i].first + j < 8;j++){
if(table[corr[i].second-j][corr[i].first+j] == 'B'){
break;
}else{
table[corr[i].second-j][corr[i].first+j] = 'B';
}
}
}else{
for(int j = 1;corr[i].second - j >= 0 && corr[i].first + j < 8;j++){
if(table[corr[i].second-j][corr[i].first+j] == 'W'){
break;
}else{
table[corr[i].second-j][corr[i].first+j] = 'W';
}
}
}
}
if(up_left(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j = 1;corr[i].second - j >= 0 && corr[i].first - j >= 0;j++){
if(table[corr[i].second-j][corr[i].first-j] == 'B'){
break;
}else{
table[corr[i].second-j][corr[i].first-j] = 'B';
}
}
}else{
for(int j = 1;corr[i].second - j >= 0 && corr[i].first - j >= 0;j++){
if(table[corr[i].second-j][corr[i].first-j] == 'W'){
break;
}else{
table[corr[i].second-j][corr[i].first-j] = 'W';
}
}
}
}
if(down_right(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j = 1;corr[i].second + j < 8 && corr[i].first + j < 8;j++){
if(table[corr[i].second+j][corr[i].first+j] == 'B'){
break;
}else{
table[corr[i].second+j][corr[i].first+j] = 'B';
}
}
}else{
for(int j = 1;corr[i].second + j < 8 && corr[i].first + j < 8;j++){
if(table[corr[i].second+j][corr[i].first+j] == 'W'){
break;
}else{
table[corr[i].second+j][corr[i].first+j] = 'W';
}
}
}
}
if(down_left(corr[i].first, corr[i].second, table, turn) == 1){
if(turn == 0){
for(int j = 1;corr[i].second + j < 8 && corr[i].first - j >= 0;j++){
if(table[corr[i].second+j][corr[i].first-j] == 'B'){
break;
}else{
table[corr[i].second+j][corr[i].first-j] = 'B';
}
}
}else{
for(int j = 1;corr[i].second + j < 8 && corr[i].first - j >= 0;j++){
if(table[corr[i].second+j][corr[i].first-j] == 'W'){
break;
}else{
table[corr[i].second+j][corr[i].first-j] = 'W';
}
}
}
}
}
int b= 0, w = 0;
for(int i =0; i < 8; i++){
for(int j =0; j < 8; j++){
if(table[i][j] == 'B'){
b++;
}else if(table[i][j] == 'W'){
w++;
}
}
}
for(int i =0; i < 8; i++){
for(int j =0; j < 8; j++){
cout << table[i][j];
}
cout << "\n";
}
if(b > w){
cout << "black wins";
}else if(w > b){
cout << "white wins";
}else{
cout << "draw";
}
}