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

S5. Maximum Strategic Savings

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

의견: 0

설명

A long time ago in a galaxy far, far away, there are \(N\) planets numbered from \(1\) to \(N\). Each planet has \(M\) cities numbered from \(1\) to \(M\). Let city \(f\) of planet \(e\) be denoted as \((e, f)\).

There are \(N \times P\) two-way
flights in the galaxy. For every planet \(e\) \((1 \le e \le N)\), there are \(P\)
flights numbered from \(1\) to \(P\). Flight \(i\) connects cities \((e,a_i)\) and \((e,b_i)\) and costs \(c_i\) energy daily to maintain.

There are \(M \times Q\) two-way
portals in the galaxy. For all cities with number \(f\) \((1 \le f \le M)\), there are \(Q\)
portals numbered from \(1\) to \(Q\). Portal \(j\) connects cities \((x_j, f)\) and \((y_j, f)\) and costs \(z_j\) energy daily to maintain.

It is possible to travel between any two cities in the galaxy using
only flights and/or portals.

Hard times have fallen on the galaxy. It was decided that some
flights and/or portals should be shut down to save as much energy as
possible, but it should remain possible to travel between any two cities
afterwards.

What is the maximum sum of energy that can be saved daily?

제약

\((1 \le e \le N)\)
\((1 \le f \le M)\)
\((1\le N,M,P,Q \le 10^5)\)
\((1 \le a_i, b_i \le M, 1 \le c_i \le 10^8)\)
\((1 \le x_j, y_j \le N, 1 \le z_j \le 10^8)\)
\(P,Q \le 100\)
\(1 \le i \le P\)
\(1 \le j \le Q\)
\(P,Q \le 200\)
\(N,M \le 200\)

입력 형식

The first line contains four space-separated integers \(N\), \(M\), \(P\), \(Q\)
\((1\le N,M,P,Q \le 10^5)\).

Then \(P\) lines follow; the \(i\)-th one contains three space-separated
integers \(a_i\), \(b_i\), \(c_i\) \((1 \le a_i, b_i \le M, 1 \le c_i \le 10^8)\).

Then \(Q\) lines follow; the \(j\)-th one contains three space-separated
integers \(x_j\), \(y_j\), \(z_j\) \((1 \le x_j, y_j \le N, 1 \le z_j \le 10^8)\).

It is guaranteed that it will be possible to travel between any two
cities using flights and/or portals. There may be multiple
flights/portals between the same pair of cities or a flight/portal
between a city and itself.

For 2 of the 15 available marks, \(P,Q \le 100\) and \(c_i = 1\) for all
\(1 \le i \le P\), and \(z_j = 1\) for all \(1 \le j \le Q\).

For an additional 2 of the 15 available marks, \(P,Q \le 200\).

For an additional 5 of the 15 available marks, \(N,M \le 200\).

출력 형식

Output a single integer, the maximum sum of energy that can be saved
daily.

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

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

출처 CCC 2018 Senior

평가 및 의견

S5. Maximum Strategic Savings

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

Log in to rate problems.

개별 의견

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

풀이 제출

S5. Maximum Strategic Savings

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