#P17462. [GESP202609 八级] 末班车
[GESP202609 八级] 末班车
Problem Description
There are subway stations and subway lines in a city. The stations are numbered in order.
For the -th subway line (), trains run in one direction from station to station . The latest departure time is minute , and the travel time is minutes. From minute to minute , there is a train departing from station every minute. A train that departs at minute () will arrive at station at minute . Passengers on this train may transfer to any train of any line departing from station at minute or later.
Now there are queries. The -th query () gives the starting station , the destination station , and the departure time . You need to determine whether it is possible to reach station when departing from station at minute . Departing from station at minute means you may take any train on any line that departs from station at minute or later.
Input Format
The first line contains three positive integers , representing the number of stations, the number of subway lines, and the number of queries.
The next lines each contain four integers , representing the starting station, the ending station, the latest departure time, and the required travel time of the line.
The next lines each contain three integers , representing the trip start, the trip destination, and the departure time.
Output Format
Output lines in total. For each query, if it is possible to reach station when departing from station at minute , output Yes; otherwise output No. Note that the output is case-sensitive.
3 4 5
1 2 3 3
2 3 5 2
3 1 4 1
1 3 0 6
1 3 2
2 1 2
2 1 3
3 2 2
3 2 3
Yes
Yes
No
Yes
No
Hint
For of the test points, it is guaranteed that .
For all test points, it is guaranteed that:
Translated by ChatGPT 5