Suppose you are working in some audio streaming service. The service has n active users…
- User
Suppose you are working in some audio streaming service. The service has n active users and 109
tracks users can listen to. Users can like tracks and, based on likes, the service should recommend them new tracks.
Tracks are numbered from 1 to 109. It turned out that tracks the i-th user likes form a segment [li,ri]
.
Let's say that the user j is a predictor for user i (j≠i) if user j likes all tracks the i
-th user likes (and, possibly, some other tracks too).
Also, let's say that a track is strongly recommended for user i if the track is not liked by the i-th user yet, but it is liked by every predictor for the i
-th user.
Calculate the number of strongly recommended tracks for each user i . If a user doesn't have any predictors, then print 0
for that user. Input
The first line contains one integer t (1≤t≤104) — the number of test cases. Next, t
cases follow.
The first line of each test case contains one integer n (1≤n≤2⋅105
) — the number of users.
The next n lines contain two integers li and ri per line (1≤li≤ri≤109) — the segment of tracks the i
-th user likes.
Additional constraint on the input: the sum of n over all test cases doesn't exceed 2⋅105
. Output
For each test case, print n integers, where the i-th integer is the number of strongly recommended tracks for the i-th user (or 0, if that user doesn't have any predictors). solve this in c++
- Assistant