#P17462. [GESP202609 八级] 末班车

    ID: 19991 远端评测题 1000ms 512MiB 尝试: 2 已通过: 1 显示难度普及+/提高− 上传者: 标签>图论最短路2026GESP

[GESP202609 八级] 末班车

Problem Description

There are nn subway stations and mm subway lines in a city. The stations are numbered 1,2,…,n1,2,\ldots,n in order.

For the ii-th subway line (1≤i≤m1\le i\le m), trains run in one direction from station uiu_i to station viv_i. The latest departure time is minute lil_i, and the travel time is tit_i minutes. From minute 00 to minute lil_i, there is a train departing from station uiu_i every minute. A train that departs at minute xx (0≤x≤li0\le x\le l_i) will arrive at station viv_i at minute x+tix+t_i. Passengers on this train may transfer to any train of any line departing from station viv_i at minute x+tix+t_i or later.

Now there are qq queries. The ii-th query (1≤i≤q1\le i\le q) gives the starting station xix_i, the destination station yiy_i, and the departure time sis_i. You need to determine whether it is possible to reach station yiy_i when departing from station xix_i at minute sis_i. Departing from station xix_i at minute sis_i means you may take any train on any line that departs from station xix_i at minute sis_i or later.

Input Format

The first line contains three positive integers n,m,qn,m,q, representing the number of stations, the number of subway lines, and the number of queries.

The next mm lines each contain four integers ui,vi,li,tiu_i,v_i,l_i,t_i, representing the starting station, the ending station, the latest departure time, and the required travel time of the line.

The next qq lines each contain three integers xi,yi,six_i,y_i,s_i, representing the trip start, the trip destination, and the departure time.

Output Format

Output qq lines in total. For each query, if it is possible to reach station yiy_i when departing from station xix_i at minute sis_i, 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 40%40\% of the test points, it is guaranteed that q≤100q\le 100.

For all test points, it is guaranteed that:

  • 1≤n≤5001\le n\le 500
  • 1≤m≤10001\le m\le 1000
  • 1≤q≤5×1051\le q\le 5\times 10^5
  • 1≤ui,vi,xi,yi≤n1\le u_i,v_i,x_i,y_i\le n
  • 0≤li,si≤1050\le l_i,s_i\le 10^5
  • 1≤ti≤1041\le t_i\le 10^4

Translated by ChatGPT 5