F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Art Class

Time Limit: 14000/7000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 635    Accepted Submission(s): 139


Problem Description
This class is on art. Mr. Picasso gives every baby a piece of white drawing paper and let them paint on it.

Baby Volcano is going to color the drawing paper black. For convenience, the drawing paper can be regarded as a Cartesian coordinate system, and initially, all points on it is white.

Baby Volcano plans to paint the drawing paper in $n$ steps. In the $i$th step, he will color rectangular $R_i$ black, where the lower left corner of $R_i$ is $(l_i,0)$, the upper right corner of $R_i$ is $(r_i,h_i)$.

Let $P_i$ be the drawing paper after the first $i$ steps, your task is to calculate the perimeter of black area on $P_i$.
 

Input
The first line contains a single integer $t(1 \leq t \leq 100)$, the number of testcases.

For each testcase, the first line contains a single integer $n(1 \leq n \leq 2 \times 10^5)$, the number of steps.

Then $n$ lines follow. Each line contains $3$ integers $l_i,r_i,h_i (1 \leq l_i, < r_i \leq 10^9, 1 \leq h_i \leq 10^9)$.

The input guarantees that there are no more than $3$ testcases with $n > 1000$.
 

Output
For each testcase, output $n$ lines. Each line contains a single integer, representing the perimeter of black area after the first $i$ steps.
 

Sample Input
1 6 1 2 2 3 4 3 5 6 2 1 4 1 2 6 1 3 7 4
 

Sample Output
6 14 20 20 20 22
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-06 01:01:46, Gzip enabled