Logo
(追記) (追記ここまで)

27848번 - Moo Route II 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB227908049.080%

문제

Bessie is on vacation! Due to some recent technological advances, Bessie will travel via technologically sophisticated flights, which can even time travel. Furthermore, there are no issues if two "parallel" versions of Bessie ever meet.

In the country there are $N$ airports numbered 1,ドル 2, \ldots, N$ and $M$ time-traveling flights (1ドル\leq N, M \leq 200000$). Flight $j$ leaves airport $c_j$ at time $r_j,ドル and arrives in airport $d_j$ at time $s_j$ (0ドル \leq r_j, s_j \leq 10^9,ドル $s_j < r_j$ is possible). In addition, she must leave $a_i$ time for a layover at airport $i$ (1ドル\le a_i\le 10^9$). (That is to say, if Bessie takes a flight arriving in airport $i$ at time $s,ドル she can then transfer to a flight leaving the airport at time $r$ if $r \geq s + a_i$. The layovers do not affect when Bessie arrives at an airport.)

Bessie starts at city 1ドル$ at time 0ドル$. For each airport from 1ドル$ to $N,ドル what is the earliest time when Bessie can get to at it?

입력

The first line of input contains $N$ and $M$.

The next $M$ lines describe flights. The $j$th of these lines contains $c_j,ドル $r_j,ドル $d_j,ドル $s_j$ in that order. (1ドル\leq c_j, d_j \leq N,ドル 0ドル\leq r_j, s_j \leq 10^9$)

The next line describes airports. It contains $N$ space separated integers, $a_1, \ldots, a_N$.

출력

There are $N$ lines of output. Line $i$ contains the earliest time when Bessie can get to airport $i,ドル or -1 if it is not possible for Bessie to get to that airport.

제한

예제 입력 1

3 3
1 0 2 10
2 11 2 0
2 1 3 20
10 1 10

예제 출력 1

0
0
20

Bessie can take the 3 flights in the listed order, which allows her to arrive at airports 1 and 2 at time 0, and airport 3 at time 20.

Note that this route passes through airport 2 twice, first from time 10-11 and then from time 0-1.

예제 입력 2

3 3
1 0 2 10
2 10 2 0
2 1 3 20
10 1 10

예제 출력 2

0
10
-1

In this case, Bessie can take flight 1, arriving at airport 2 at time 10. However, she does not arrive in time to also take flight 2, since the departure time is 10 and she cannot make a 1 time-unit layover.

힌트

출처

Olympiad > USA Computing Olympiad > 2022-2023 Season > USACO 2023 February Contest > Silver 3번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /