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

Baltazar

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

의견: 0

설명

Baltazar decided to go on a vacation. Currently, he is in Baltazargrad, and wants
to travel to Primošten. To get there, he has to go through many cities. There are
\(n\) citites, and they are connected with \(m\) t\(wo-wa\)y roads. Baltazargrad is labeled
as city no. 1, and Primošten as city no. \(n\).
Baltazar isn’t sure about the route from Baltazargrad to Primošten, so he will use
GPS. It will lead him to his destination using the shortest route.
But Baltazar really likes to travel, and he can pour his magic potion on any road
(even the ones he won’t pass by), and increase its length by 2 kilometers. He can pour it on only one
road.
Soon he realized that he has to che\(ck-in\) in the hotel Zora in Primošten before noon, so he can’t increase
the length of the shortest route too much. Now, he wants to know how many roads can he pour his magic
potion on, so that the shortest distance between Baltazargrad and Primošten increases by exactly 1
kilometer.
Help him determine the roads he can pour his magic potion on.

제약

Subtask 1 (15 points): n, \(m \le 1\,000\)

Subtask 2 (30 points): There is a road between Baltazargrad and Primošten, and its length is 1 kilometer longer than the shortest distance between these cities.

Subtask 3 (65 points): No additional constraints.

입력 형식

Each test contains multiple test cases. The first line contains the number of test cases \(t\) (\(1 \le t \le 10\,000\)).
The description of the test cases follows.
The first line of each test case contains integers \(n\) and \(m\) (\(2 \le n \le 300\,000\), \(1 \le m \le mi\)n(300 000, {n}{(}{−}
2
),
the number of cities, and the number of roads between cities.
The following \(m\) lines contain integers \(a_{i}\), \(b_{i}\) i \(w_{i}\) (\(1 \le a_{i}\), \(b_{i} \le n\), \(a_{i}\)̸ = \(b_{i}\), \(1 \le w_{i} \le 10^{9}\)), meaning there is
a road between cities \(a@@RISE_MATH_BLOCK_0@@i\), and its length is \(w\)\(i\). Between each pair of cities, there is at most one road
connecting them.
All the cities are connected, i.e., for each pair of cities, there is a path from one to another, but not
necessary direct.
It is guaranteed that the sum of \(n\) over all test cases does not exceed 300 000, and that the sum of \(m\) over
all test cases does not exceed 300 000.

출력 형식

In the first line, print the integer \(c\), the number of roads on which Baltazar can pour his magic potion. In
the second line, print \(c\) integers, the indices of the roads in increasing order.

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

1

15점

n, \(m \le 1\,000\)

2

30점

There is a road between Baltazargrad and Primošten, and its length is 1 kilometer longer than the shortest distance between these cities.

3

65점

No additional constraints.

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

Clarification of the example:
The cities and the roads are shown in the image. If Baltazar pours his magic potion on road 2 (between
cities 1 and 3), or on road 4 (between cities 3 and 5), then the shortest distance between cities 1 and n
will increase by 1.

문제 정보

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

출처 COCI 2022/2023 Contest 3

평가 및 의견

Baltazar

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

Log in to rate problems.

개별 의견

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

풀이 제출

Baltazar

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