Problem A
Pyramid
Input: Standard Input
Output: Standard Output
Time Limit: 2 Seconds
When the creature lands on a cell, it changes color: from red to green, green to blue or blue to red. Given how the cells are initially colored, determine a jumping sequence containing no more than 5000 jumps that turns all the cells into blue. You are allowed to start from any cell in the pyramid you want (this guarantees that there will always be a solution). The first cell to change color is the one reached after jumping from the start cell.
Input
The input ends with a case where n is 0, which should not be processed.
Output
For
each test case, output two lines. The first line should contain two integers,
the creatures start position in the pyramid. The first integer is the row (1
being the top row) and the second integer is the cell in that row (1
being the leftmost cell). The next line should contain a string describing the
jumps. The length of this string should be at most 5000 characters. Each
character should either be a '7' (jumping up-left), a '9'
(up-right), a '1' (down-left) or a '3' (down-right). Any solution
that has no more than 5000 jumps and which turns all cells into blue
will be accepted.
4 B RG BGR GBRB 2 R GB 0 |
3 1 193919193919373737717191991919373737 2 1 919
|
Problemsetter: Jimmy Mårdell, Member of Elite Problemsetters' Panel
I majored in music composition at Florida State University in the late 1960s. I minored in watching demonstrations, dodging bayonnets, eating buttered spaghetti, gorging on week-end buffets, and pursuing women. Despite objections including a visit to the dean, I was forced to take a mathematics course where I first encountered reason. Though painful, it was refreshing.