Submission

Status:

PPPPPPPPPPPPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: NovemNotes

Problemset: Othello

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-16 16:21:18

#include <bits/stdc++.h>
using namespace std;

vector<pair<int,int>> vp = {{1,0},{-1,0},{0,-1},{0,1},{1,1},{-1,1},{1,-1},{-1,-1}};
const int N = 10;
int cnt=0;
vector<vector<char>> tab(N,vector<char>(N,'_'));
bool turn = true;
int b=0,w=0;

void show(vector<vector<char>> &v){
    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++){
            cout << v[i][j];
        }cout << "\n";
    }
    // cout << "--------------------\n";
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    for(int i=1;i<=8;i++){
        for(int j=1;j<=8;j++){
            cin >> tab[i][j];
            if(tab[i][j]!='_')cnt++;
            if(tab[i][j]=='B')b++;
            else if(tab[i][j]=='W') w++;
        }
    }
    int x,y;
    while(cin >> x >> y){
        x++,y++;
        if((x==0&&y==0)||cnt==64)break;
        if(tab[x][y]=='_'){
            if(turn){
                tab[x][y]='B';b++;cnt++;
            }else{
                tab[x][y]='W';w++;cnt++;
            }
            char want = tab[x][y];
            for(auto [nx,ny]:vp){
                
                int num=0;
                bool f=false;
                int tx=x+nx,ty=y+ny;
                while(true){
                    if(tx<1||ty<1||tx>8||ty>8||tab[tx][ty]=='_')break;
                    if(tab[tx][ty]==want){
                        f=true;
                        break;
                    }
                    tx+=nx,ty+=ny;
                    num++;
                }
                // cout << num << "\n";
                if(!f)continue;
                else{
                    int tmpx=x,tmpy=y;
                    // cout << x << " " << y << " " ;
                    x+=nx,y+=ny;
                    // cout << x << " " << y << "\n";
                    while(num--){
                        tab[x][y]=want;
                        x+=nx,y+=ny;
                        if(turn)b++,w--;
                        else w++,b--;
                    }
                    x=tmpx,y=tmpy;
                }
            }
            turn = !turn;
        }
    }
    show(tab);
    // cout << b << " " << w << "\n";
    if(b>w)cout << "black wins\n";
    else if(w>b)cout << "white wins\n";
    else cout << "draw\n";
    return 0;
}