# Game Logic

• April 1st, 2013, 06:09 AM
sumit.gupta.sgt
Game Logic
Blitz Cyvasse(Can Anybody make Java Code for This Problem)->
Tyrion Lannister is a master player of cyvasse, a game of strategy and war similar to chess. He has challenged
Bronn, the captain of his guard, during Joffrey Baratheon’s nameday celebrations. In his inebriated state,
Tyrion is finding it harder and harder to beat Bronn as the evening wears on. Unfortunately, he has staked
too much in his pride and it is imperative that he win all games to avoid humiliation.
Cyvasse is played with a grid of n x m cells (n rows and m columns), with tiles of grass, forest, water or
mountains covering each cell. Players have pieces occupying tiles corresponding to infantry, cavalry, artillery
and one dragon each. Players can attack their own pieces too. Tyrion decides to use his dragon to destroy an
entire row of the board at a time. Bronn being not so experienced, simply mirrors Tyrion’s tactics. However,
there is a catch. In subsequent moves, a player can only destroy a row with number of corresponding tile
position differing from that of the last destroyed row as an odd prime. Two tile positions differ if they one is
filled and other is empty. Eg. 1100011 and 0001000 differ at 5 positions which is odd prime. ‘1’ denotes a
filled position and ‘0’ denotes an empty position. Both of them mutually decide to concede when they have
no move left.
Given n, m and the state of each tile (occupied or unoccupied), does Tyrion have a winning strategy if he
takes he first move?
Input
First line contains T , the number of test cases. T test cases follow.
First line of each test case contain 2 space separated integers n and m as specified above.
An nxm matrix follows denoting the initial state of the game. A ‘1’ denotes that the position is filled up. ‘0’
denotes an empty position
Constraints
n <= 100
m <= 1000
Output
For each test case, output on a separate line “YES” (quotes for clarity) if he has a winning strategy else
“NO” (quotes for clarity)
Sample Input
3
10 11
11110000000
11111111110
11111111000
11000000000
11000000000
11111000000
10000000000
11111110000
11111000000
11111000000
8 11
1
• April 1st, 2013, 09:07 AM
Norm
Re: Game Logic
• April 1st, 2013, 01:03 PM
sumit.gupta.sgt
Re: Game Logic
Quote:

Originally Posted by Norm

Actually I want Java Code for this Game.