WOSS Dual Olympiad 2023 S2: Geese Attack
View as PDFThe sky darkens... it is raining geese. Oli is on a strip of land that is  units long. He initially starts at unit 
 on the left, and every second he can teleport an integer from 
 to 
 units, either left or right. He cannot travel beyond unit 
 or beyond unit 
 on the strip. 
 squadrons of geese will rain from the sky. The 
th squadron hits the ground in 
 seconds from now, temporarily vaporizing the area stretching from units 
 to 
 inclusive. Can he avoid all the geese without getting vaporized? The strip when 
 is shown below.
Constraints
Input Specification
The first line of input contains  space-separated integers, 
, 
, and 
.
The next  lines each contain 
 space-separated integers, 
, 
, and 
. These will be sorted in increasing order of 
, all times are distinct.
Output Specification
Output a single line containing YES if he can survive and NO if he cannot.
Sample Input 1
1000 2 1
300 600 1000
0 400 1001
Sample Output 1
YES
Sample Input 2
10 6 1
0 4 11
3 7 12
8 10 13
1 2 15
4 9 16
1 7 17
Sample Output 2
YES
Sample Input 3
5 3 3
0 0 1
2 5 2
0 4 3
Sample Output 3
NO
Comments