10337 - problem1   

Description

Let’s consider the game of Gomoku (五子棋) on a 10x10-intersection board.

l   There are two players: black and white. Black plays first.

l   The two players (black, white) take turns in placing a stone of their color on an empty intersection.

l   The winner is the first player to get an unbroken line of more than five stones horizontally, vertically, or diagonally.

For the following examples, the winners are all the black stone.

 

In this problem, you will be given a current state of the board game and N individual placements of the two players. You are asked to perform these N placements and finally determine which color wins the game or just show undetermined (UNDET).

 

Note:

(1)   You need to consider the amount of the black and white stones on the current (that is, the given) board state and judge which color plays first in the following N placements.

(2)   The winner in this problem can only be determined on or after the N-th placement.

(3)   The coordinate of the board’s upper-left intersection is (0,0).

 

You may use the following piece of code:

#include 
#define B_SIZE 10

char board[B_SIZE][B_SIZE];

void read_board(){
    int i, j;
    for(i = 0; i < B_SIZE; i++){
        for(j = 0; j < B_SIZE; j++){
            scanf(" %c", &board[i][j]);
        }
    }
}

void print_board(){
    int i, j;
    for(i = 0; i < B_SIZE; i++){
        for(j = 0; j < B_SIZE; j++){
            printf(" %c", board[i][j]);
        }
        printf("\n");
    }
}

int main()
{
    int N;

    read_board();
    scanf("%d", &N);

    /* your code here */

    //print the result of the game
    print_board();
    
    return 0;
}


Input

The current state of the board game

N

Position (row, column) of the black or white stone (placement 1)

Position (row, column) of the black or white stone (placement 2)

Position (row, column) of the black or white stone (placement 3)

Position (row, column) of the black or white stone (placement N)

 

Output

There are several lines.

The first line shows “BLACK” if the black stone wins, “WHITE” if the white stone wins, or “UNDET” if the winner cannot be determined.

The following lines show the board state after these N placements.

Each entry of the board is printed using the format “ %c”, and there is a newline character at the end of the board.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss