Submission
Status:
--------------------
Subtask/Task Score:
0/100
Score: 0
User: yourmom
Problemset: Othello
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-07 16:49:59
#include <iostream>
using namespace std;
int main() {
char board[8][8];
// เริ่มต้นกระดาน
for (int r = 0; r < 8; r++) {
for (int c = 0; c < 8; c++) {
board[r][c] = '_';
}
}
int R, C;
int turn = 0; // 0 = ดำ, 1 = ขาว
while (cin >> R >> C) {
// บังคับจบเกม
if (R == -1 && C == -1) {
break;
}
// ลงหมากตามสี
if (turn == 0)
board[R][C] = 'B';
else
board[R][C] = 'W';
turn = 1 - turn;
// ตรวจสอบว่ากระดานเต็มหรือไม่
bool full = true;
for (int r = 0; r < 8; r++) {
for (int c = 0; c < 8; c++) {
if (board[r][c] == '_') {
full = false;
}
}
}
if (full) {
break;
}
}
// แสดงกระดานสุดท้าย
int black = 0, white = 0;
for (int r = 0; r < 8; r++) {
for (int c = 0; c < 8; c++) {
cout << board[r][c];
if (board[r][c] == 'B')
black++;
else if (board[r][c] == 'W')
white++;
}
cout << '\n';
}
// แสดงผลผู้ชนะ
if (black > white)
cout << "Black wins\n";
else if (white > black)
cout << "White wins\n";
else
cout << "Draw\n";
return 0;
}