FLATTEN PROBLEM A solitaire game is played given a row of N piles where each pile contains zero or more chips. See Figure 1. Piles are identified by integers 1 through N. In a move of this game you point to a pile, say p, and specify a number, say m. Then m chips are transferred from the pile p to each of its neighboring piles. See Figure 2 for an example.. Pile p has two neighbors, p-1 and p+1 if 1
3/2*B
Input
The input is a text file named flat.inp having two lines.
The first line: contains an integer giving the value of NN.
On theThe second line: there will be N integers the i th of which is the value of Ci.nonnegative integers giving the number of chips in each pile. These integers will be separated with one blank. The i’th number on the second line will be the number of chips in the pile i (1 = i = N )
Output
The output will bemust be the text file named flat.out..
The first line: must contain the number of moves. (Call this value , call it M.)
Each of the following M lines contains two integers representing a move: p, m. There must be M lines following the first line, each containing two integers, separated by one blank, representing a move. The first integer designates the id-number of the pile and the second integer represents the number specified in the move. The order of moves on the output must be the same orderthat the moves are performed. So, your first move shall be written to the second line of the output file.
Discussion
Threads about this problem. Spoilers are collapsed; wrap hints in
||double bars||.No discussion yet. Start a thread if something here needs explaining.