Tuesday, December 1, 2009
Good and bad part of marriage :)
What do you say???
Monday, October 12, 2009
Probelm posted in a recent coding competition...
“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 |