Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
7 views3 pages

Problem A. Omnes Viae Yokohamam Ducunt?: 3000 Ms 1048576 KB Windows

The document outlines a problem regarding the construction of a highway network in the Kingdom of Kanagawa, connecting various cities to the capital, Yokohama. The goal is to create a non-redundant network that minimizes total risk severity from natural disasters, calculated based on city significance and segment vulnerability. The input format includes the number of cities, candidate segments, and their respective significance and vulnerability values, with the output being the minimum possible total risk severity.
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)
7 views3 pages

Problem A. Omnes Viae Yokohamam Ducunt?: 3000 Ms 1048576 KB Windows

The document outlines a problem regarding the construction of a highway network in the Kingdom of Kanagawa, connecting various cities to the capital, Yokohama. The goal is to create a non-redundant network that minimizes total risk severity from natural disasters, calculated based on city significance and segment vulnerability. The input format includes the number of cities, candidate segments, and their respective significance and vulnerability values, with the output being the minimum possible total risk severity.
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/ 3

FINAL GYM ISA Jul 27, 2025

Problem A. Omnes Viae Yokohamam Ducunt?


Time Limit 3000 ms
Mem Limit 1048576 kB
OS Windows

"Omnes viae Romam ducunt" is an old Latin proverb meaning "all roads lead to Rome." It
is still desirable to have access to the capital from all the regions of a country.

The Kingdom of Kanagawa has a number of cities, including the capital city, Yokohama.
The Ministry of Transport of the Kingdom is now planning to construct a highway
network, connecting all those cities.

There are a number of candidate highway segments, each of which directly connects two
cities. A highway network is a set of highway segments chosen from the candidates. The
following are required for the highway network.

All the cities should be connected via highway segments in the network, directly or
indirectly.
To save the budget, the minimum number of segments should be chosen. In other
words, the highway network should not be redundant; the path connecting any pair
of cities should be unique.

The highway network should be made resistant to natural disasters, with the limited
budget. The emphasis is placed on accessibility to and from the capital city, Yokohama. As
the network is planned to be non-redundant, when one segment becomes unavailable due
to a natural disaster, some of the cities become inaccessible from Yokohama.

We want to minimize the total risk severity, defined as follows.

The cities in the Kingdom have different populations and economic scales, based on
which, the cities are assigned certain significance values. Given a highway network, the
damage suffered from a natural disaster on a single segment in the network is estimated
by the sum of the significance values of such cities made inaccessible from Yokohama.

Vulnerabilities to natural disasters are assessed for all the candidate segments. The risk
severity of a segment is calculated as the product of its estimated damage and
vulnerability. The total risk severity of the network is estimated as the sum of the risk
severities of all the segments in the network.

-
FINAL GYM ISA Jul 27, 2025

Your task is to determine the minimum total risk severity by appropriately designing the
highway network.

Input

The input consists of a single test case of the following format.

nm

p1 ⋯ pn
​ ​

u1 v1 q1​ ​ ​

um vm qm ​ ​ ​

The first two integers n and m (2≤ n ≤ 105 , 1 ≤ m ≤ 3 × 105 ) describe the numbers of
cities and highway segment candidates, respectively. The cities are numbered from 1 to n,
with Yokohama numbered 1. The second line contains n integers p1 , … , pn , where each ​ ​

pi (1 ≤ pi ≤ 1000) represents the significance value assigned to the city numbered i.


​ ​

The following m lines describe the candidate highway segments. The j -th line of them
contains three integers uj , vj , and qj (1≤ uj < vj ≤ n, 1 ≤ qj ≤ 106 ), meaning that the
​ ​ ​ ​ ​ ​

segment candidate connecting cities numbered uj and vj has the vulnerability qj . Each
​ ​ ​

pair (uj , vj ) appears at most once in the input.


​ ​

It is guaranteed that one or more highway networks that connect all the cities can be
designed using some of these segments.

Output

Output a line containing the minimum possible total risk severity.

Examples

-
FINAL GYM ISA Jul 27, 2025

Input Output

3 3 16
1 2 3
1 2 2
2 3 3
1 3 4

Input Output

5 7 210
2 6 7 7 10
1 5 8
1 4 6
3 4 9
2 3 6
2 4 7
1 3 4
4 5 4

You might also like