WOSS Dual Olympiad 2023 S2: Geese Attack

View as PDF

Submit solution


Points: 10
Time limit: 2.0s
Memory limit: 1G

Authors:
Problem type

The sky darkens... it is raining geese. Oli is on a strip of land that is N units long. He initially starts at unit 0 on the left, and every second he can teleport an integer from 0 to K units, either left or right. He cannot travel beyond unit N or beyond unit 0 on the strip. M squadrons of geese will rain from the sky. The ith squadron hits the ground in ti+0.5 seconds from now, temporarily vaporizing the area stretching from units ai to bi inclusive. Can he avoid all the geese without getting vaporized? The strip when N=12 is shown below.

Constraints

1N,K109

1M104

0aibiN

1ti104

Input Specification

The first line of input contains 3 space-separated integers, N, M, and K.

The next M lines each contain 3 space-separated integers, ai, bi, and ti. These will be sorted in increasing order of ti, all times are distinct.

Output Specification

Output a single line containing YES if he can survive and NO if he cannot.

Sample Input 1

Copy
1000 2 1
300 600 1000
0 400 1001

Sample Output 1

Copy
YES

Sample Input 2

Copy
10 6 1
0 4 11
3 7 12
8 10 13
1 2 15
4 9 16
1 7 17

Sample Output 2

Copy
YES

Sample Input 3

Copy
5 3 3
0 0 1
2 5 2
0 4 3

Sample Output 3

Copy
NO

Comments

There are no comments at the moment.