UVa 141:the Spot Game

Source: Internet
Author: User

Topic Link:

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=77

Type: Hash weight + Impersonation

Original title:

The game of the Spot is played on a NxN board as shown below for N = 4. During the game, alternate players may either place a black counter (spot) in a empty square or remove one from the board , thus producing a variety of patterns. If a board pattern (or its rotation to degrees or 180 degrees) is repeated during a game, the player producing that Pat Tern loses and the other player wins. The game terminates in a draw over 2N moves if no duplicate pattern is produced before.

Consider the following patterns:

If the had been produced earlier, then any of the following three (plus one is not patterns) shown Terminate the game, whereas the last one would not.

Input and Output

Input would consist of a series of games, each consisting of the size of the board, N (2

N

followed, on separate lines, by 2N moves, whether they-are all necessary or not. Each move would consist of the coordinates of a square (integers in the range 1..N) followed by a blank and a character ' + ' or '-' indicating the addition or removal of a spot respectively. You may assume this all moves are legal, which is there'll never be a spot on attempt square, occupied To remove a non-existent spot. Input is terminated by a zero (0).

Output would consist of one line for each game indicating which player won and on which move, or that game ended in a D Raw.

Sample input

2
1 1 +
2 2 +
2 2-1 2 + 2 1 1
+ 2
2 + 1
2 +
2 2-
0

Sample output

Player 2 wins on move 3
Draw

The main effect of the topic:

There's a game on the N*n board called Spot, it consists of two players in turn on the board to place pieces or remove pieces, once one player placed or removed a pawn, the board of the display state or the turntable rotation 90 degrees, 180 degrees is before the show, then he lost.

Analysis and Summary:

I took a look at the submission record of this question, WA 17 times altogether

What is the reason that this is not a difficult problem that I wa thoroughly disgusting? Let's get closer to science.

Let me wa The reason:

1. The chessboard is not 4*4, but n*n. WA got n times.

2. Rotation problem. The topic is actually a little vague, just say rotate 90 degrees and 180 degrees. I thought there were 4 states to determine whether or not it had happened before, but the title added (plus one, not shown), which means there is actually a state that does not give an image. What else is there? Then the title to the image through the rotation function printed out, found that the last picture is not the same, through the direction of rotation is not. This picture is actually the first mirror reflection of the figure. So the title says there's another one that doesn't show up, it's the image that rotates 180 degrees. Because of this reason WA again n times.

Such a mistake that I read the problem is still too impetuous, not sinking heart to read the question, saw a probably know the principle and thought directly to do, and then must get rid of this habit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.