“I would prefer even to fail with honor than to win by cheating” – Sophocles (one of Athens great tragic playwrights).
How true the above quote from Sophocles is, but alas, there are some people who do not agree! Take case of Jeet Arman. Jeet loves to play “War of the Liners” and also loves to win at any cost. He wins every time he plays the game with any opponent as he is a big time cheater. If you will recall, “War of the Liner” is played on a 10 by 10 crisscross with rows labeled by letters A to J and columns labeled by numbers 0 to 9. Each player places his/her five liners on the crisscross. The liner sizes are 5, 4, 3, 3 and 2 crisscross squares long, and they must be placed either horizontally or vertically but not diagonally. The crisscross below shows one possible arrangement of the liners:
The objective of the game is to submerge your opponents’ liners by attacking various crisscross locations. When you announce the crisscross square you are attacking, your opponent tells you whether it was “strike” (i.e. one of his liners was on that square and was hit) or a “float” (i.e., none of his liners were on that square).
Using the above example, if Jeet’s opponent attacked crisscross square C6, a truthful player would declare that it was a “strike”, but not Jeet! He would simply move his liner to a new location that was not attacked till now and respond that it was a “float”! Remember Jeet wants to win at any cost; therefore he follows each attack made by his opponent, and continuously moves his liners to locations which have not been attacked till now. In the above example, he could move the liner one row up or down, but not two rows down since that would bump into another liner (though he could then move that liner) and not one column to the right, since his liner will still lie on C6. If his opponent had previously attacked C1, then Jeet could not move his liner one column over to the left either.
Your objective of this problem is to assist Jeet in ascertaining if he can place all his liners after a series of attacks on a board whose initial configuration looks like the above figure.
Input
The input file may contain multiple test cases. Input for each test case consist of a single line of the form m K1 K2 K3 . . . Km (0
Output
For each test case, output either the word “Yes” or “No” (without the double quotes and without any extra white spaces or special characters before and after the word) depending on whether or not Jeet can still place his liners without any being struck.
An example of multiple test cases
Input | Output |
14 J0 A4 D1 I1 B3 C2 E1 A9 D6 B8 E5 F4 G3 C7 20 A4 B3 C2 D1 E0 A9 B8 C7 D6 E5 F4 G3 H2 I1 J0 F9 G8 H7 I6 J5 0 | Yes No |
yeh kya hai be? psychooo!!
ReplyDeletei agree, its a psychooo problem.. i couldnt solve it anyways :)
ReplyDeletepost a Diwali blog !!
ReplyDeleteWell this problem reminds me of similar game which we used to play. It was called as "country war". Instead of words we used to have weapons like airplanes ( represented by 'A' and can be placed "T" shape, 3 horizontal and 2 vertical), bombs (5 B's placed vertical) , tankers (5 T's horizontal) and missiles (5 M's placed diagonal). But the rule of the game was we should not change once we place all our weapons in the field.
ReplyDeleteSo we couldn't cheat :(
The game is interesting.
Questions :
1. Does it have a cap on minimum or maximum number of tries ? like you should try to find all words in 5 or 10 trials ? (It says max is 82 here)
2. In the input file example above, E5 seems to be repeated in 14th and 20th guess, how can we repeat the same input, don't i know that it was a strike or false in the previous guess ?
. its like a cell is attacked. and if that cell is part of an element then u try to move the element and if you are able to move the element its good.. otherwise its hit.. and your answer would be no..
ReplyDelete2. a person could attack any cell.. its like a user keeps attacking any cell at random...
do u have the codes for this problem..its urgent mail it within 3 hours..
ReplyDeletemy email id:sanu.alam6@gmail.com
@Shahnawaz fwd me also....
ReplyDeletebhai shanu sabko chahiye....:P
ReplyDeleteThis comment has been removed by the author.
ReplyDeletemy mail id rohit.1290@gmail.com
ReplyDeletesapna dekho....
Delete