RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0560

Moo Route II

Platinum V 플래티넘 V
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

*Note: The time limit for this problem is 4s, twice the default.*

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?

Problem credits: Brandon Wang

제약

SCORING

  • Inputs 3-5: \(r_j < s_j\) for all \(j\), i.e. all flights arrive after they depart.
  • Inputs 6-10: \(N, M \leq 5000\)
  • Inputs 11-20: No additional constraints.

Problem credits: Brandon Wang

입력 형식

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
출력
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
출력
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.

문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2022-2023 > February > Silver

태그

평가 및 의견

Moo Route II

개요
출제자 난이도 Platinum V 플래티넘 V 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Moo Route II

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8