UVa 141:The Spot Game

题目链接:

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

类型: 哈希判重 + 模拟

原题:

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

Consider the following patterns:

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

Input and Output

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

N

50) followed, on separate lines, by 2N moves, whether they are all necessary or not. Each move will 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 that all moves are legal, that is there will never be an attempt to place a spot on an occupied square, nor to remove a non-existent spot. Input will be terminated by a zero (0).

Output will consist of one line for each game indicating which player won and on which move, or that the game ended in a draw.

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

题目大意:

有一个在N*N棋盘上玩的游戏叫做Spot,  它由两个玩家轮流在棋盘上放置棋子或移除棋子, 一旦其中一个玩家放置或者移除棋子之后,那个棋盘的摆放状态或者这个转台旋转90度,180度是之前是出现过的,那么他就输了。

分析与总结:

看了下我做这题的提交记录, 一共WA了17次

到底是什么原因使得这并不难题的一题让我WA得彻底恶心了?让我们走近科学。

让我WA的原因:

1.  棋盘并不是4*4的,而是N*N的。  WA了n次。

2.  旋转问题。 题目其实说得有点含糊,只是说旋转90度和180度。 我就以为共有4种状态要判断之前是否出现过,但是题目上又说了 (plus one other not shown)  ,也就是说其实还有一个状态没有给出图像。 还有一个是什么呢? 于是把题目给的图像通过旋转函数打印了出来, 发现最后一副图是不一样的,通过旋转方向根本就得不到。 这幅图实际上是第一个的镜面反射的图。 所以题目说的还有一个没有显示出来的,是旋转180度的那个图像。 因为这个原因又WA了n次。

这样的错误说明我读题还是太浮躁了,沉不下心来好好读懂题意,看了个大概知道了原理和思路就直接做了,以后一定要改掉这个习惯。

以上是小编为您精心准备的的内容,在的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索题目
, pattern
, 一个
, of
, The
棋盘
game spot、spot the liar、spot rate、blindspot、g spot,以便于您获取更多的相关知识。

时间: 2024-07-28 21:51:39

UVa 141:The Spot Game的相关文章

uva 141 - The Spot Game

点击打开链接 题目意思:     有两个人在玩游戏,游戏是在长为N的正方形棋盘,上面是由一序列格子组成,现在输入一些操作指令由两个人轮流操作,每一次操作对应的棋盘上面会有一个状态,如果当前的状态或这个状态旋转90或180度而来的状态以及出现过,那么这个人就输,如果当所有指令操作完以后还没分胜负就是平局 解题思路:       set+状态判重即可,注意对set里面放结构体的使用,重载<号.                        1:我们知道对于set和map而言,插入的数据默认是那些常见

uva 141 The Spot Game hash

  很简单的hash,可以知道只需要保存每行每列的总个数即可唯一确定图,所以只需开两个50的数组即可,然后对最长为100的字符串进行hash,一开始想直接ELF,但后来发现还是有重复,懒得写拉链法了,直接用map,0.008s就过了 /* author:jxy lang:C/C++ university:China,Xidian University **If you need to reprint,please indicate the source** */ #include <iostre

UVa 1422:Processor 任务处理问题

题目大意:有n个任务送到处理器处理,每个任务信息包括r,d,w,r代表开始时间,w代表必须要结束的时间,w指需要多少时间处理. 其中处理器的处理速度可以变速,问处理器最小需要多大速度才能完成工作? 输入: 3 5 1 4 2 3 6 3 4 5 2 4 7 2 5 8 1 6 1 7 25 4 8 10 7 10 5 8 11 5 10 13 10 11 13 5 8 15 18 10 20 24 16 8 15 33 11 14 14 1 6 16 16 19 12 3 5 12 22 25

UVa 10905:Children&#039;s Game

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1846 类型: 排序 There are lots of number games for children. These games are pretty easy to play but not so easy to make. We will

UVa 10763:Foreign Exchange

题目链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1704 原题: Your non-profit organization (iCORE - international Confederation of Revolver Enthusiasts) coordinates a very succes

UVa 10341: Solve It

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1282 原题: Solve the equation:        p*e-x + q*sin(x) + r*cos(x) + s*tan(x) + t*x2 + u = 0        where 0 <= x <= 1. Input

UVa 10057:A mid-summer night&#039;s dream.

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=998 原题: This is year 2200AD. Science has progressed a lot in two hundred years. Two hundred years is mentioned here because thi

UVa 10487:Closest Sums

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1428 原题: Given is a set of integers and then a sequence of queries. A query gives you a number and asks to find a sum of two di

UVa 10340:All in All

链接: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=113&page=show_problem&problem=1281 原题: You have devised a new encryption technique which encodes a message by inserting between its characters randomly gener