OTHS Coding Competition 3 (Mock CCC) S3 - Domain Expansion

View as PDF

Submit solution

Points: 10 (partial)
Time limit: 3.0s
Java 5.0s
Python 5.0s
Memory limit: 512M
Java 1G
Python 1G

Author:
Problem type

N jujutsu sorcerers are on a battlefield which can be represented by a line with K regions. Each sorcerer uses their domain expansion, with the ith sorcerer's domain expansion covering and controlling all regions from li to ri, inclusive, and having strength si. It is guaranteed that no two sorcerer's domain expansions have the same strength. If a region is covered by two or more domain expansions, it will be controlled by the strongest one.

How many regions are controlled by each jujutsu sorcerer's domain expansion?

Constraints

1N5×105

1K109

1liriK

1si109

All values of si are unique.

Subtask 1 [2/15]

1N,K100

Subtask 2 [4/15]

1N3×103

Subtask 3 [4/15]

1K106

Subtask 4 [5/15]

No additional constraints.

Input Specification

The first line of input contains N and K, representing the number of people and the number of regions.

The next N lines of input each contain li,ri,si, representing the range covered by the ith sorcerer's domain expansion and its strength.

Output Specification

Output N space separated integers, with the ith integer representing how many regions the ith sorcerer's domain expansion controls.

Sample Input 1

Copy
2 5
1 3 1
3 5 2

Sample Output 1

Copy
2 3

Explanation for Sample Output 1

The first sorcerer's domain expansion covers regions 1,2,3. The second sorcerer's domain expansion covers regions 3,4,5. Region 3 is controlled by the second sorcerer's domain expansion as it is stronger.

Sample Input 2

Copy
4 10
1 5 1
1 1 100
3 4 2
7 10 3

Sample Output 2

Copy
2 1 2 4

Comments

There are no comments at the moment.