#400
Unrated
Fine Dining
시간 제한
2s
메모리 제한
1024MB
제출
0
정답
0
맞힌 사람
0
정답 비율
0.0%

문제

The cows are heading back to the barn at the end of a long day, feeling both tired and hungry.

The farm consists of NN pastures (2N50,0002 \leq N \leq 50,000), conveniently numbered 1N1 \dots N. The cows all want to travel to the barn in pasture NN. Each of the other N1N-1 pastures contains a cow. Cows can move from pasture to pasture via a set of MM undirected trails (1M100,0001 \leq M \leq 100,000). The iith trail connects a pair of pastures aia_i and bib_i, and requires time tit_i to traverse. Every cow can reach the barn through a sequence of trails.

Being hungry, the cows are interested in potentially stopping for food on their way home. Conveniently, KK of the pastures contain tasty haybales (1KN1 \leq K \leq N), with the iith such haybale having a yumminess value of yiy_i. Each cow is willing to stop at a single haybale along her trip to the barn, but only if the amount of time this adds to her path is at most the yumminess of the haybale she visits. Note that a cow only "officially" visits at most one haybale for dining purposes, although it is fine if her path takes her through other pastures containing haybales; she simply ignores these.

입력

The first line contains three space-separated integers NN, MM, and KK. Each of the next MM lines contains three integers aia_i, bib_i, and tit_i, describing a trail between pastures aia_i and bib_i which takes tit_i time to traverse (aia_i and bib_i are different from each-other, and tit_i is a positive integer at most 10410^4)

The next KK lines each describe a haybale in terms of two integers: the index of its pasture, and its yumminess value (a positive integer at most 10910^9). Multiple haybales can reside in the same pasture.

출력

The output should consist of N1N-1 lines. Line ii contains the single integer 11 if the cow at pasture ii can visit and dine on a haybale on the way to the barn, and 00 otherwise.

예제 입력 1

4 5 1
1 4 10
2 1 20
4 2 3
2 3 5
4 3 2
2 7

예제 출력 1

1
1
1
코드 제출

코드를 제출하려면 로그인이 필요합니다.

로그인
내 제출
제출 내역이 없습니다.
맞은 사람
아직 맞은 사람이 없습니다.
난이도 투표
Unrated0명 투표
로그인 후 AC 받으면 투표할 수 있습니다.
전체 제출
제출 내역이 없습니다.