home
compete
practice
rank
blog
LOGIN
Practice
>>
Rectangle Union
Rectangle Union
Time Limit:
2 sec
Memory Limit:
256 MB
Attempts:
143
Accuracy:
6.29%
Author:
savish bedi
Problem Statement
My Submissions
All Submissions
You are given
n
points on the cartesian coordinate system numbered from
1
to
n
,
(x
_{1}
,y
_{1}
) , (x
_{2}
,y
_{2}
) ,..........(x
_{n}
,y
_{n}
).
There are
n
rectangles on the coordinate plane numbered from
1
to
n
.
(0, 0)
and
(x
_{i}
, y
_{i}
)
are the opposite corners of the
i
^{th}
rectangle.
Find the union of area of all the rectangles.
Input Format:
The first line of the input contains a single integer
T
denoting the number of test cases.
The first line of each test case contains one integer
n
The following
n
lines consists of two integers
x
_{i}
, y
_{i}
denoting the
x
coordinate and
y
coordinate of the
i
^{th}
point.
Output Format:
Print one integer — the union of area of the rectangles.
Constraints:
1 ≤
T
≤ 30
1 ≤
n
≤ 10
^{5}
1 ≤
x
_{i}
, y
_{i}
≤ 10
^{6}
Sample Input:
2
2
1 2
2 1
3
2 1
3 3
4 2
Sample Output:
3
11
Log In
ID
SUBMITTED AT
STATUS
LANGUAGE
TIME
MEMORY USED
See More
USER
TIME
STATUS
LANGUAGE
TIME
MEMORY USED
LEADERBOARD
See More
RECENT
See More