Fence Construction
Time limit0.1sMemory limit1024 MB
Given N rectangles added one at a time, print the perimeter of the bounding rectangle of all buildings so far after each addition.
- Level
Easy1 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Puang village builds a fence around the outskirts of the village to protect it from the threat of poor grades (학점). Each building is a rectangle on a 2D plane, with lower-left corner and upper-right corner . Puang village has world-class construction skills, so buildings may overlap. The fence is the smallest rectangle that encloses every building in the village, and its sides must be parallel to the x-axis or the y-axis. The cost of the fence is its perimeter.
By the village's iron rule that fences must be sturdy, each time a building is added, the existing fence is torn down and a new one is installed. The village starts with no buildings and constructs buildings one at a time. After each building is built, print the cost of the fence construction.
Input
The first line contains the number of buildings to construct. Each of the next lines contains four integers , , , and , separated by spaces, which describe the -th building to be constructed.
Output
Print lines. The -th line contains the fence construction cost after the -th building is built.
Constraints
- All given coordinates are integers.