0% found this document useful (0 votes)
39 views

CSEC-ASTU Competitive Programming Contest 2021 Problem 97: Dark Roads

The document describes a problem from a competitive programming contest involving optimizing road lighting in the city of Byteland. The government wants to save money by switching off some street lights but still ensure all junctions remain connected by illuminated paths. The input specifies the road network and the task is to calculate the maximum daily savings possible without disconnecting the network. Sample input and output are provided for test cases.

Uploaded by

Abraham Mekuria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

CSEC-ASTU Competitive Programming Contest 2021 Problem 97: Dark Roads

The document describes a problem from a competitive programming contest involving optimizing road lighting in the city of Byteland. The government wants to save money by switching off some street lights but still ensure all junctions remain connected by illuminated paths. The input specifies the road network and the task is to calculate the maximum daily savings possible without disconnecting the network. Sample input and output are provided for test cases.

Uploaded by

Abraham Mekuria
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Mikiyas Yonas

CSEC-ASTU Competitive Programming Contest 2021


Problem 97: Dark roads
Time limit: 2s
Economic times these days are tough, even in Byteland. To reduce the operating costs,
the government of Byteland has decided to optimize the road lighting. Till now every
road was illuminated all night long, which costs 1 Bytelandian Dollar per meter and
day. To save money, they decided to no longer illuminate every road, but to switch off
the road lighting of some streets. To make sure that the inhabitants of Byteland still feel
safe, they want to optimize the lighting in such a way, that after darkening some streets
at night, there will still be at least one illuminated path from every junction in Byteland
to every other junction.
What is the maximum daily amount of money the government of Byteland can save,
without making their inhabitants feel unsafe?

Input
The input file contains several test cases. Each test case starts with two numbers m and n, the
number of junctions in Byteland and the number of roads in Byteland, respectively. Input is
terminated by m = n = 0. Otherwise, 1 ≤ m ≤ 200000 and m − 1 ≤ n ≤ 200000. Then follow n
integer triples x, y, z specifying that there will be a bidirectional road between x and y with
length z meters (0 ≤ x, y < m and x != y). The graph specified by each test case is connected.
The total length of all roads in each test case is less than 2 31.

Output
For each test case print one line containing the maximum daily amount the government
can save.

Sample Input Sample Output


7 11 51
0 17
0 35
1 28
1 39
1 47
2 45
3 4 15
3 56
4 58
4 69
5 6 11
0 0

Source: UVA Andalus Division Aug 03

You might also like