Submission
Status:
PP-PPP-PPPPP-P----PP
Subtask/Task Score:
65/100
Score: 65
User: theem1502
Problemset: Othello
Language: c
Time: 0.002 second
Submitted On: 2025-09-25 17:31:41
#include <stdio.h>
#include <stdlib.h>
int main() {
char thearray[10][10];
for (int i = 0; i < 10; i++) {
thearray[0][i] = '_';
thearray[i][0] = '_';
thearray[9][i] = '_';
thearray[i][9] = '_';
}
for (int i = 0; i < 8; i++) {
char tempstring[9];
scanf("%s", tempstring);
for (int j = 0; j < 8; j++) {
thearray[i+1][j+1] = tempstring[j];
}
}
for (int i = 0; i < 10000; i++) {
int currentx = 0, currenty = 0;
scanf("%d %d", ¤tx, ¤ty);
currentx++;
currenty++;
if (currentx == 0 && currenty == 0) {
break;
}
char opposite;
int currentchar;
if (i % 2 == 0) {
thearray[currentx][currenty] = 'B';
opposite = 'W';
currentchar = 'B';
}
else {
thearray[currentx][currenty] = 'W';
opposite = 'B';
currentchar = 'W';
}
int checked = 0;
if (thearray[currentx-1][currenty] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currentx - j < 0 ) {
break;
}
int currentcoordinates = thearray[currentx-j][currenty];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx-j][currenty] = currentchar;
}
}
}
if (thearray[currentx-1][currenty+1] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currentx - j < 0 || currenty + j > 7) {
break;
}
int currentcoordinates = thearray[currentx-j][currenty+j];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx-j][currenty+j] = currentchar;
}
}
}
if (thearray[currentx-1][currenty-1] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currentx - j < 0 || currenty - j < 0) {
break;
}
int currentcoordinates = thearray[currentx-j][currenty-j];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx-j][currenty-j] = currentchar;
}
}
}
if (thearray[currentx][currenty+1] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currenty + j > 7) {
break;
}
int currentcoordinates = thearray[currentx][currenty+j];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx][currenty+j] = currentchar;
}
}
}
if (thearray[currentx][currenty-1] == opposite) {
int check = 0;
int thecount = 0;
for (int j = 1; j <= 7; j++) {
if (currenty - j < 0) {
break;
}
int currentcoordinates = thearray[currentx][currenty-j];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx][currenty-j] = currentchar;
}
}
}
if (thearray[currentx+1][currenty] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currentx + j > 7) {
break;
}
int currentcoordinates = thearray[currentx+j][currenty];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx+j][currenty] = currentchar;
}
}
}
if (thearray[currentx+1][currenty-1] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currentx + j > 7 || currenty - j < 0) {
break;
}
int currentcoordinates = thearray[currentx+j][currenty-j];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx+j][currenty-j] = currentchar;
}
}
}
if (thearray[currentx+1][currenty+1] == opposite) {
int thecount = 0;
int check = 0;
for (int j = 1; j <= 7; j++) {
if (currentx + j > 7 || currenty + j > 7) {
break;
}
int currentcoordinates = thearray[currentx+j][currenty+j];
if (currentcoordinates == opposite) {
thecount++;
continue;
}
else if (currentcoordinates == '_') {
break;
}
else if (currentcoordinates == currentchar) {
check = 1;
break;
}
}
if (check == 1) {
for (int j = 1; j <= thecount; j++) {
thearray[currentx+j][currenty+j] = currentchar;
}
}
}
int tempsum = 0;
for (int i = 1; i < 9; i++) {
for (int j = 1; j < 9; j++) {
if (thearray[i][j] != '_') {
tempsum++;
}
}
}
if (tempsum == 64) {
break;
}
}
for (int i = 1; i < 9; i ++) {
for (int j = 1; j < 9; j++) {
printf("%c", thearray[i][j]);
}
printf("\n");
}
int whitecount = 0;
int blackcount = 0;
for (int i = 1; i < 9; i++) {
for (int j = 1; j < 9; j++) {
if (thearray[i][j] == 'B') {
blackcount++;
}
else if(thearray[i][j] == 'W') {
whitecount++;
}
}
}
if (blackcount == whitecount) {
printf("%s", "draw");
}
else if (blackcount > whitecount) {
printf("%s","black wins");
}
else {
printf("%s", "white wins");
}
}