#P3810. 【模板】三维偏序 / 陌上花开

    ID: 2747 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>树状数组cdq 分治O2优化分治排序概率论,统计K-D Tree

【模板】三维偏序 / 陌上花开

Description

There are n n elements. The i i -th element has three attributes ai,bi,ci a_i, b_i, c_i . Let f(i) f(i) be the number of j j such that ajai a_j \leq a_i , bjbi b_j \leq b_i , cjci c_j \leq c_i , and ji j \ne i .

For all d[0,n) d \in [0, n) , find the number of i i such that f(i)=d f(i) = d .

Input Format

The first line contains two integers n,k n,k , denoting the number of elements and the maximum attribute value.

The next n n lines each contain three integers ai,bi,ci a_i ,b_i,c_i , representing the three attribute values.

Output Format

Output n n lines. The d+1 d + 1 -th line contains the number of i i such that f(i)=d f(i) = d .

10 3
3 3 3
2 3 3
2 3 1
3 1 1
3 1 2
1 3 1
1 1 2
1 2 2
1 3 2
1 2 1

3
1
3
0
1
0
1
0
0
1

Hint

For all testdata, it is guaranteed that 1n105 1 \leq n \leq 10^51ai,bi,cik2×1051 \leq a_i, b_i, c_i \le k \leq 2 \times 10^5 .

Translated by ChatGPT 5