#P7146. [THUPC 2021 初赛] 独立
[THUPC 2021 初赛] 独立
Description
You are given an undirected graph with vertices and edges.
For a subset of , the score of is defined as follows:
- The initial score is .
- For all , add to the score.
- For every edge (meaning an edge between and with value ) such that and , subtract from the score.
Now, among all subsets , compute the maximum possible score.
Input Format
Let , , .
The first line contains six integers (, , ).
For , .
For , , , . Each triple describes an edge connecting and with value . If or an edge connecting and has appeared before, ignore this edge (i.e., this edge does not exist).
Output Format
Output one line with one integer, the maximum score.
10 5 1 2 3 4
3909327860
Hint
[Source]
From the 2021 Tsinghua University Student Programming Contest and Collegiate Invitational (THUPC2021) Preliminary Round.
Resources such as editorials can be found at https://github.com/THUSAAC/THUPC2021-pre.
Translated by ChatGPT 5
京公网安备 11011102002149号