2201. Jumps

单点时限: 2.0 sec

内存限制: 256 MB

“Jumps” is a board game played on an infinite tape of squares. The board has neither left nor right limit. On the squares there is finitely many pieces (more than one piece on a square is allowed). We assume that the most left, non-empty square is numbered 0. Squares on the right are denoted by consecutive natural numbers 1, 2, 3, …, squares on the left - by negative numbers: -1, -2, -3, … . The configuration of pieces on the board can be described in the following way: for every square occupied by at least one piece we give the number of the square and the number of pieces standing on this square. There are two kinds of moves that can change the configuration: jump right and jump left. Jump right consists of removing two pieces from the board: one from a square p and the other from the square p+1, and placing one piece on the square p+2. Jump left consists of removing a piece from a square p+2 and placing two pieces on the board: one on the square p+1 and the other on the square p. We say that a configuration is final if each pair of neighbouring squares contains at most one piece. For every configuration there is exactly one final configuration that can be reached after finite number of moves (jumps).

Write a program that:

  • reads a description of an initial configuration,

  • finds the final configuration that can be reached from the given initial configuration and writes the result.

输入格式

In the first line there is one positive integer n, 1 <= n <= 10000, which equals the number of non-empty squares of the given initial configuration. In each of the following n lines there is a description of one non-empty square of the initial configuration. Such a description consists of two integers. First is the number of the square, second - the number of pieces standing on this square. The descriptions are given in increasing order with respect to numbers of squares. The biggest number of a square is not greater than 10000 and the number of pieces on a single square is not greater than 100000000.

输出格式

In the first line there should be written the final configuration that can be reached from the given initial configuration. More precisely the line should contain the numbers of non-empty squares (in increasing order) of the final configuration. The numbers should be separated by single spaces.

样例

Input
2
0 5
3 3
Output
-4 -1 1 3 5

0 人解决,1 人已尝试。

0 份提交通过,共有 1 份提交。

9.9 EMB 奖励。

创建: 16 年,4 月前.

修改: 7 年,2 月前.

最后提交: 16 年,4 月前.

来源: POI 1997 I Stage

题目标签