#C4907. Resilient Highway Network
Resilient Highway Network
Resilient Highway Network
You are given a network of highways connecting n cities and m highways. Each highway is represented by a triple of integers u, v, and w, where u and v are two distinct cities and w is the weight of the highway. The cities are numbered from 1 to n.
The task is to determine if the highway system is resilient. Formally, let \(G = (V, E)\) be an undirected graph where \(V\) is the set of cities and \(E\) is the set of highways. The highway system is said to be resilient if, for every highway \(e \in E\), the graph \(G' = (V, E \setminus \{e\})\) remains connected. Otherwise, the system is vulnerable if there exists at least one highway removal that disconnects the network.
Return The highway system is resilient.
if the system is resilient, or The highway system is vulnerable.
otherwise.
inputFormat
The first line of input contains two integers n and m representing the number of cities and highways respectively.
This is followed by m lines, each containing three integers: u, v, and w. Here, u and v denote the cities connected by a highway and w denotes its weight. Cities are 1-indexed.
outputFormat
Output a single line containing either The highway system is resilient.
if the network remains connected after removing any single highway, or The highway system is vulnerable.
if it does not.
5 6
1 2 10
1 3 20
2 3 30
3 4 40
4 5 50
3 5 60
The highway system is resilient.