All submissions for this problem are available.
Both Roman and Tej like to play with Lego. A new LEGO game has been launched recently and due to high demand only one last set of game is available in the market. Since only one of them can have it so both decided to play a game.
The description of game is as follows:
There are 'N' heaps of Legos with each heap containing 'k' number of Lego pieces. The heaps will be kept on a raised platform in non decreasing order.Once the heaps have been aranged in given manner both Roman and Tej will be allowed to remove at least one piece from any of the heaps in an alternate fashion.The heaps can be any continous subsequence of length at least two. While removing the pieces from the heaps it needs to be taken care that non decreasing order of heaps remains maintained. The person who cannot make the valid move will loose.
In our question assuming Roman will always start the game you have to tell for how many possible heaps's combination will he win the game?
-The first line contains an integer N denoting the number of heaps
-The next line will consist of N numbers with each number denoting the number of pieces in the ith heap
-The answer to question denoting the number of ways in which Roman can win the game.
Input: 3 3 3 4 Output: 2
For the above input there are three valid possible arrangements.
Out of 3,the arrangements for which Roman will win are:
The arrangements for which he will loose are:
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2|
Fetching successful submissions
If you are still having problems, see a sample solution here.