|시간 제한||메모리 제한||제출||정답||맞힌 사람||정답 비율|
|60 초 (추가 시간 없음)||512 MB||0||0||0||0.000%|
You have a robot on an infinite east-west highway, and it has a cake to deliver. Every mile along the highway, in both directions, there is a lamppost. You want to program the robot to move exactly N lampposts to the east, and release the cake there. The route does not have to be direct, as long as the robot eventually releases the cake in the right place.
Unfortunately, the robot comes equipped with only very little memory, and it is capable of no advanced logic. To control the robot you will have to give it a very simple program at the start that will get it to release the cake at the proper location. This program must be composed of one or more statements, each of which tells the robot what to do under certain conditions. These statements must be in the following format:
<S> <M> -> <action>
which means that if all of the following conditions are met:
then it will perform exactly one of the following actions:
<action>must be formatted as
"<D> <NS> <NM>", where
Dis the direction to move (use 'W' for west and 'E' for east),
NSis the robot's new state and
NMis the new mark for the current lightpost.
<action>must be formatted as
If you output two or more statements with the same values of
M, the robot will misbehave and destroy the cake.
If at any time the robot is in a state X at a lamppost marked with Y such that there is no statement with
M=Y, then the robot will get confused and eat the cake.
All states and marks must be integers with absolute value no greater than one million (106). Assume that initially the robot is in state zero and all lampposts are marked with zero.
Given N, write a program so the robot releases the cake in the appropriate place. Your program must use at most 30 statements, and it must terminate within X steps.
The first line of the input gives the number of test cases, T. T test cases follow. Each test case consists of a single line containing an integer N, which indicates the lamppost where the robot must release the cake.
For each test case, first output "Case #x: y", where x is the number of the test case (starting with 1) and y is the number of statements you will use. Next output y lines, each of which represents a statement for the robot in the format described previously.
3 0 4 0
Case #1: 1 0 0 -> R Case #2: 5 0 0 -> E 1 1 1 0 -> E 2 1 2 0 -> E 3 1 3 0 -> E -1 1 -1 0 -> R Case #3: 3 0 0 -> E 1 1 0 1 -> R 1 0 -> W 0 1
In the first case, the robot is initially in state zero, and there is a zero on the lamppost. So it executes its only statement, which is to release the cake.
In the second case, the robot has five states: 0, 1, 2, 3, and -1. The robot performs the following actions:
In the third case, the robot has two states, and performs the following actions:
Note that the robot takes different actions at the two times it is in state 0, because it sees a different mark each time.