CF2042D Recommendations

题目描述

有 $n$ 个区间 $S_i=[l_i,r_i]$,对于每个区间求出 $|\bigcap\limits_{j} S_j|-|S_i|$,其中 $j\neq i$,且 $S_i\subseteq S_j$。即对于每个区间求出其包区间交集的大小,并减去自己的大小。

输入格式

$T(1\le t\le 10^4)$ 组测试数据。 每组数据第一行输入 $n(1\le n\le 2\times 10^5)$ 表示区间个数,$\sum\limits n\le 2\times 10^5$。 接下来 $n$ 行,每行两个整数 $l_i,r_i(1\le l_i,r_i\le 10^9)$ 表示区间范围。

输出格式

对于每组测试数据,输出 $n$ 行表示第 $i$ 个答案。如果第 $i$ 个区间没有包区间,则直接输出 $0$。 translated by xyin

说明/提示

In the first test case: - the first user has no predictors; - the second user has no predictors; - the third user has two predictors: users $ 1 $ and $ 2 $ ; only track $ 3 $ is liked by both of them and not liked by the third user. In the second test case, the second user is a predictor for the first user. Therefore, all tracks, except $ 42 $ , are strongly recommended for the first user. In the third test case, the first user has two predictors: users $ 2 $ and $ 3 $ , but there is no track that is liked by them and not liked by the first user himself.