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

Tramvaji

Unrated 레이팅 미적용
난이도
1s
시간 제한
512MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

One magical night Patrik and Josip were talking about the number 42 and the
meaning of life. They were interrupted by the famous lady voice in the tram: The
next stop \(is\) Jordanovac. Patrik and Josip were distracted by this common sentence
and started discussing:
Patrik: It is a very short ride between Joranovac and Maksimir, isn’t it?
Josip: It is, but the ride between Mašićeva and Kvatrić is way shorter.
Patrik: Really? I disagree.
Josip: I wonder, which is the shortest ride between all stations?
Paula, a big public traffic transport, was carefully listening to their conversation. The problem of finding
the shortest ride interested her so much that she stayed in the tram longer than she intended just to listen
to their conversation.
At each station (except for the first one, when they entered the tram) one of the following two things
happened:
• Patrik said: t minutes have passed since \(we\) entered the tram
• Josip said: From station y \(to\) this station t minutes have passed
But before Paula could hear their conclusion about which ride was the shortest, they left the tram!
Luckily, Paula remembers all their statements. Now she needs your help! Help her find the duration of
the shortest ride and between which two stations the tram drove on that ride.

제약

Subtask 1 (12 points): \(t_{i} \le 1\,000\)

Subtask 2 (13 points): Every sentence was said by Patrik.

Subtask 3 (25 points): No additional constraints.

입력 형식

The first line contains the integer \(n\) (\(2 \le n \le 1\,000\)), the number of tram stations.
The \(i-th\) of the following \(n - 1\) lines contains the information about station \(i + 1\) in one of the following
formats:
• Patrik \(t@@RISE_MATH_BLOCK_0@@i\) (\(1 \le t\)\(i \le 10^{9}\))
• Josip \(y_{i}\) \(t_{i}\) – Duration of the ride between station \(y\) and station \(i + 1\) is \(t_{i}\) (\(y_{i} < i + 1\), \(1 \le t_{i} \le 10^{9}\))
Every station will be in a distinct position.

출력 형식

In one line output three numbers: t, x1, x2, the duration of the shortest ride and the indices of the starting
and ending stations of that ride.
If multiple solutions exist, print the one with the smallest indices of the stations.

서브태스크
서브태스크점수설명

1

12점

\(t_{i} \le 1\,000\)

2

13점

Every sentence was said by Patrik.

3

25점

No additional constraints.

예제 1
입력
4
Patrik 3
Patrik 5
Josip 1 7
출력
2 2 3
예제 2
입력
2
Josip 1 5
출력
5 1 2
예제 3
입력
5
Patrik 4
Josip 2 4
Josip 2 6
Josip 4 2
출력
2 3 4
설명

Clarification of the first example:
The tram drove for 3 minutes from the first to the second station, and 5 from the first to the third. We
can conclude that from the second to the third station it took 2 minutes, which is the shortest ride.
Clarification of the third example:
The ride between the fourth and fifth station is also 2 minutes but, because they have greater indices,
only the 2 3 4 solution is accepted.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2022/2023 Contest 2

평가 및 의견

Tramvaji

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Tramvaji

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