题号:NC221185
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld
题目描述
A Dyson Sphere is a hypothetical megastructure that completely encompasses a star and captures a large percentage of its power output. The concept is a thought experiment that attempts to explain how a spacefaring civilization would meet its energy requirements once those requirements exceed what can be generated from the home planet's resources alone. Only a tiny fraction of a star's energy emissions reach the surface of any orbiting planet. Building structures encircling a star would enable a civilization to harvest far more energy.
One day, Moca has another idea for a thought experiment. Assume there is a special box called Dyson Box. The gravitational field in this box is unstable. The direction of the gravity inside the box can not be determined until it is opened.
The inside of the box can be formed as a
-dimensional grid, while the bottom left corner's coordinate is
and the upper right corner's coordinate is
. There will be
events. In the
-th event, a new cube will appear, whose upper right corner's coordinate is
and bottom left corner's coordinate is
.
There are two directions of gravity in the box, vertical and horizontal. Suppose Moca opens the box after the
-th event. In that case, she has
probability of seeing the direction of the gravity inside the box is vertical, and the other
probability is horizontal. And then, she will measure the total length of the outline of all the cubes. If the direction of gravity is horizontal, all the cubes inside will move horizontally to the left under its influence. Similarly, vertical gravity will cause all the cubes to move downward.
Moca hates probability, so that she is asking for your help. If you have known the coordinates of all the cubes in chronological order, can you calculate the total length of these two cases after each event?
输入描述:
The first line contains one integer
)
-- the number of cubes.
Each of the following

lines describes a cube with two integers
)
.
It is guaranteed that no two cubes have the same coordinates.
输出描述:
For each of the
cubes, print one line containing two integers -- two answers when the the direction of gravity is vertical and horizontal.