14273 - Gomoku Battle   

Description

This afternoon, Doraemon and DebugCatCapoo have a Gomoku battle.
However, they've slightly altered the rules since Capoo often ends up secretly eating the pieces Doraemon puts down...

In their version of Gomoku, Doraemon goes first. On his turn, he can put his pieces on two empty spots. When it's Capoo's turn, he puts his piece on one empty spot, and then picks a spot with a piece on it to remove (eat) that piece.

To simplify the rules, their game's goal is to form an unbroken line of 5+ pieces of their own color either horizontally or vertically, and the lines going diagonally don't count. If someone tries to play out of turn, that move is ignored. It's guaranteed that both players will not place pieces on occupied spaces or outside the board, and Capoo will not attempt to remove (eat) a piece from an empty space or outside the board.

This is a partial judge problem. Write a program to determine the winner of their Gomoku game. Please review the provided code and implement the section marked TODO in function.h.

 

Input

This problem consists of several test cases.

Each test case begins with a line containing an integer 5 ≤ N ≤ 10, which indicates the game is played on an N×N board. The lines that follow are formatted as <Doraemon/DebugCatCapoo> <location> <location>, where each location is a two-digit string, indicating the action taken by the player. There are no more than 100 actions taken by the two players for each round of the game.

For example, the actions taken by the players are represented as follows:

  • Doraemon 35 03 means Doraemon places pieces on row 3, column 5, and row 0, column 3.
  • DebugCatCapoo 32 04 means DebugCatCapoo places a piece on row 3, column 2, and removes a piece from row 0, column 4.

Please note that sometimes a player may take action even when it's not their turn. For example, in the second action of round #1 in the sample input, it's DebugCatCapoo's turn, but Doraemon takes an action. In such cases, the move made by Doraemon will be ignored until DebugCatCapoo performs its move. You need to verify the value of GomokuGame::turn within the GomokuGame::place() and GomokuGame::remove(). If it's not the correct player's turn, return false to abort the action.

A string of - - - marks the end of a test case and the conclusion of the game.

 

Output

The winner of the game and the status of the board will be outputted.
(O -> Doraemon, X -> DebugCatCapoo, this part is already implemented)

 

Sample Input  Download

Sample Output  Download

Partial Judge Code

14273.cpp

Partial Judge Header

14273.h

Tags




Discuss