15 人解决,22 人已尝试。
20 份提交通过,共有 47 份提交。
5.1 EMB 奖励。
单点时限: 2.0 sec
内存限制: 256 MB
The cook at the Frobbozz Magic Pancake House sometimes falls asleep on the job while cooking pancakes. As a result, one side of a stack of pancakes is often burned. Clearly, it is bad business to serve visibly burned pancakes to the patrons. Before serving, the waitress will arrange the stacks of pancakes so that the burned sides are facing down. You must write a program to aid the waitress in stacking the pancakes correctly.
We start with a stack of
For example (+ indicates burned bottom, - a burned top):
+1 -3 -2 [flip 2] -->
+3 -1 -2 [flip 1] -->
-3 -1 -2 [flip 3] -->
+2 +1 +3 [flip 1] -->
-2 +1 +3 [flip 2] -->
-1 +2 +3 [flip 1] -->
+1 +2 +3
You must write a program which finds a sequence of at most
The first line of the input contains a single decimal integer, -
) or down (+
).
For each dataset, you should generate one line of output with the following values: The dataset number as a decimal integer (start counting at one), a space, the number of flips (3 2 3
is also a solution to the first problem below.
3 3 +1 -3 -2 4 -3 +1 -2 -4 5 +1 +2 +3 +4 -5
1 6 2 1 3 1 2 1 2 6 4 1 4 3 1 2 3 3 5 1 5
15 人解决,22 人已尝试。
20 份提交通过,共有 47 份提交。
5.1 EMB 奖励。