#FT0000218. Đếm quan hệ thứ tự ba chiều (3D Partial Order)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm quan hệ thứ tự ba chiều (3D Partial Order)
3D Partial Order
Source: Luogu
Version: Phuoc Hung OJ Extended
Problem Statement
There are elements; element has three positive integer attributes . Elements are distinguished by their indices, even when all three attributes are equal.
For each index , let be the number of other elements satisfying all three inequalities:
For every integer from to , count how many indices satisfy .
Input
- The first line contains two integers : the number of elements and the maximum allowed coordinate.
- Each of the following lines contains three integers describing element .
Output
Print lines. Line , for , contains the number of indices satisfying .
Subtasks
-
Subtask 1 (20 points): ; for all .
-
Subtask 2 (30 points): ; for all .
-
Subtask 3 (50 points): ; for all .
Examples
Input
5 4
1 1 1
2 2 2
1 2 2
2 2 2
3 1 1
Output
1
2
0
2
0
Explanation
Element dominates no other indexed element, so . Elements and each dominate only element , so both have . Elements and share coordinates ; each dominates element , element , and the other identical-coordinate element, giving . Thus the histogram for is .