Submit | All submissions | Best solutions | Back to list |
SHELL - Shell game |
Your program is to play the traditional "shell" game (see Shell_game). The game is played as follows:
There is a person called an operator; he/she has 3 identical, non-transparent hollow objects - shells, and a metal ball, which he/she places under one of these objects. Then, the operator quickly swaps pairs of shells several times; if shells at positions A and B are swapped, and the ball is under the shell at position A, it moves under the shell at position B. In the end, you have to guess which shell the ball is under.
The shells are identical, and positions mean immediate position that you see (left will always denote the leftmost shell, not the shell that was leftmost in the beginning).
Input
The first line of input contains one string - "left", "center" or "right", denoting the position of the shell the ball is under in the beginning. The second line contains an integer N<=10, denoting the number of swaps. N lines follow, all of them contain 2 strings - positions of 2 shells which are swapped.
Output
Output position of the shell the ball is under after all swaps are performed.
Warning
Testing simulates the exact progress of an actual game! There are 10 testcases; in the last one only, N = 10. You're likely to get a WA on this last test case, even if your program seems correct. Remember, it's like an actual game!
Example
Input: left 2 left right right center Output: center
Explanation
In the beginning, the ball is under the left shell. After swap 1, it's under the right shell. After swap 2, it's under the center shell.
Added by: | Xellos |
Date: | 2011-12-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | people.ksp.sk/~acm |
hide comments
|
|||||||||||
2012-04-11 16:34:47 Jakub ©afin
Did I by any chance say that there are onyl 3 possible positions of the ball? And do you think there are only 3 points in our entire space? |
|||||||||||
2012-04-11 16:34:47 Walrus
WTF problem of the year \m/ Since the code gives WA on last data, the only one with N =10, I tried to output all three possibilities, "left" "center" and "right" for N = 10, but I got WA each time, which means that the problem setter is expecting an output which he has not clearly defined in the problem statement !! Last edit: 2012-02-20 05:07:27 |
|||||||||||
2012-04-11 16:34:47 Mr. Malice
finally after 4 WAs !! |
|||||||||||
2012-04-11 16:34:47 Chandan Giri
@jakub nice twist to the problem!!! :) |
|||||||||||
2012-04-11 16:34:47 Jakub ©afin
Ah... sorry, never heard that word before If you want a riddle, try problem CRYPTO, which is in the classical set. I, personally, don't agree with putting such problems in tutorial, because "tutorial" is supposed to be the basics of programming or using an online judge. I think such problems are most fit for the challenge set... but this is actually mostly about being able to write a game simulator, and the trick is just about paying attention to every word of the problem description, and NOT about guessing or using comments to the fullest! The simplest problems in the classical set don't need any great algorithmic thinking, either... But I'm glad there's finally a normal comment, not just "don't solve this", "move this to tutorial" :D |
|||||||||||
2012-04-11 16:34:47 Alex Anderson
Due to the fact that the last test case, as said by many people in the comments, is not exactly...logical... As in, it isn't really a programming related algorithm. Really, what is the point of this problem, aside from to trick people? Problems should be make people figure out an algorithm, not a trick or a riddle. If you want a riddle, see this problem: http://www.spoj.pl/problems/INFINITY/ (Note that it is in tutorial.) P.S. As you can see here: http://dictionary.reference.com/browse/wastage "wastage" is indeed an English word. Last edit: 2012-01-30 22:05:16 |
|||||||||||
2012-04-11 16:34:47 neerajcrespo
nothing to learn from this problem except knowing how comments can help you in getting AC. thanks Xeronik. |
|||||||||||
2012-04-11 16:34:47 Jialin Ouyang
The author knew nothing about ACM. The WORST problem I've ever seen. |
|||||||||||
2012-04-11 16:34:47 punit_
My answer is correct for any input, y is it giving WA X( |