포럼
문제 ICPC00198

D. Disposable Switches

설명

Having recently been hired by Netwerc Industries as a network engineer, your first task is to assess their large and dated office network. After mapping out the entire network, which consists of network switches and cables between them, you get a hunch that, not only are some of the switches redundant, some of them are not used at all! Before presenting this to your boss, you decide to make a program to test your claims.

The data you have gathered consists of the map of the network, as well as the length of each cable. While you do not know the exact time it takes to send a network packet across each cable, you know that it can be calculated as \(\ell / v + c\), where
- \(\ell\) is the length of the cable,
- \(v\) is the propagation speed of the cable, and
- \(c\) is the overhead of transmitting the packet on and off the cable.

You have not been able to measure \(v\) and \(c\). The only thing you know about them is that they are real numbers satisfying \(v > 0\) and \(c \ge 0\), and that they are the same for all cables. You also know that when a network packet is being transmitted from one switch to another, the network routing algorithms will ensure that the packet takes an optimal path—a path that minimises the total transit time.

Given the map of the network and the length of each cable, determine which switches could never possibly be part of an optimal path when transmitting a network packet from switch \(1\) to switch \(n\), no matter what the values of \(v\) and \(c\) are.

제약
입력 형식

The input consists of:
- One line with two integers \(n\), \(m\) (\(2 \leq n \leq 2\,000\), \(1 \leq m \leq 10^4\)), the number of switches and the number of cables in the network. The switches are numbered from \(1\) to \(n\).
- \(m\) lines, each with three integers \(a\), \(b\) and \(\ell\) ($1 \leq a, b
\leq n\(, \)1\leq \ell \leq 10^9\(), representing\ a\ network\ cable\ of\ length \)\ell\( connecting\ switches \)a\( and \)b$.

There is at most one cable connecting a given pair of switches, and no cable connects a switch to itself. It is guaranteed that there exists a path between every pair of switches.

출력 형식

First output a line with an integer \(k\), the number of switches that could never possibly be part of an optimal path when a packet is transmitted from switch \(1\) to switch \(n\). Then output a line with \(k\) integers, the indices of the \(k\) unused switches, in increasing order.

예제 1
입력
7 8
1 2 2
1 3 1
1 4 3
2 6 1
2 7 2
3 5 1
4 7 2
5 7 1
출력
2
4 6
예제 2
입력
5 6
1 2 2
2 3 2
3 5 2
1 4 3
4 5 3
1 5 6
출력
0
예제 3
입력
5 6
1 2 2
2 3 1
3 5 2
1 4 3
4 5 3
1 5 6
출력
1
4
문제 정보

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

출처 ICPC NWERC 2019

평가 및 의견

D. Disposable Switches

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

Log in to rate problems.

개별 의견

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

풀이 제출

D. Disposable Switches

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