NOI '19 P4 - Jump

View as PDF

Submit solution

Points: 25 (partial)
Time limit: 1.0s
Memory limit: 512M

Problem types

There are n cities in Byteland numbered from 1 to n and city 1 is the capital. All cities' locations are on a w×h grid, which has an integer coordinate (x,y) (1xw,1yh). Different cities share different locations.

There are m portals in Byteland numbered from 1 to m. Portal i is located at city pi, with some constraints ti,Li,Ri,Di,Ui. With portal i, Kevin can spend ti (ti>0) transporting from pi to a city j where its location (x,y) satisfies LixRi,DiyUi (1LiRiw,1DiUih). One city may have many portals.

Starting from city 1, Kevin wants to know the least time needed to go to every city i. Note that Kevin can only transport with portals and only using portals take time. It is guaranteed that there is at least a way to go to each city i from city 1.

Input Specification

The first line contains four integers n,m,w,h.

In the following n lines, each line contains two integers xi,yi, indicating the coordinate of city i.

In the following m lines, each line contains six integers pi,ti,Li,Ri,Di,Ui, indicating constraints of portal i.

Constraints

For all test cases, 1n70000, 1m150000, 1w,hn, 1ti10000.

Test Case1n1mAdditional Constraints
1~8100100None
9~1350000100000Every portal can reach exactly 1 city, and Li=Ri,Di=Ui
14~1850000100000h=1
19~222500050000None
23~2570000150000

Output Specification

In line i, output the answer to city i+1.

Sample Input 1

Copy
5 3 5 5
1 1
3 1
4 1
2 2
3 3
1 123 1 5 1 5
1 50 1 5 1 1
3 10 2 2 2 2

Sample Output 1

Copy
50
50
60
123

Comments

There are no comments at the moment.