#P4220. [WC2018] 通道
[WC2018] 通道
Description
In the year 11328, scientists in country C developed a high-speed teleportation channel that can send residents from one end to the other in a very short time. These channels are bidirectional.
The downside is that such channels require extensive maintenance and inspection. After planning, the president of country C decided to build such channels in City M. In City M, teleportation stations and channels were built. These channels are divided into groups, each containing channels.
When any one group of channels is operating, residents can travel via this group of channels from any station to any other station. In other words, all stations are connected by channels.
The three groups of channels operate in a round-robin fashion in the order , , , repeatedly. At any moment, exactly one group of channels is available. Formally, on day , only group is operating.
The renowned scientist Access Globe is conducting a social survey experiment: collecting information on users of the channels between two stations. Access Globe’s plan is as follows:
- Choose two stations .
- On day one, he starts from , uses the currently operating group of channels to reach along a shortest path, and surveys the users on all channels he traverses.
- On day two, he starts from , uses the currently operating group of channels to reach along a shortest path, and surveys the users on all channels he traverses.
- On day three, he starts from , uses the currently operating group of channels to reach along a shortest path, and surveys the users on all channels he traverses.
Access Globe knows the number of users on each channel when it is operating. He wants to find a pair such that the total number of users over all traversed channels during the entire experiment is maximized.
Access Globe hopes you, a participant of the CCF NOI 2018 Winter Camp, can help him solve this simple problem. If you succeed, Access Globe will give you a small gift — points.
Input Format
The first line contains a positive integer , the number of stations, numbered from to .
Lines to : each line contains three numbers , indicating that in the first group there is a channel connecting and , with users when it is operating.
Lines to : each line contains three numbers , indicating that in the second group there is a channel connecting and , with users when it is operating.
Lines to : each line contains three numbers , indicating that in the third group there is a channel connecting and , with users when it is operating.
Output Format
Output a single line containing an integer: the maximum possible sum of user counts.
5
1 2 2
1 3 0
1 4 1
4 5 7
1 2 0
2 3 1
2 4 1
2 5 3
1 5 2
2 3 8
3 4 5
4 5 1
27
Hint
[Sample 1 Explanation]
The figure below shows the stations and channels in City for the sample. The alternating dotted-and-dashed lines, dotted lines, and solid lines denote the first, second, and third groups of channels, respectively.
One feasible plan is to choose . The total number of users is .
[Subtasks]
Constraints:
- For all testdata, , .
Special properties:
- Special property : Any two groups of channels are structurally identical.
- Special property : The second and third groups of channels are structurally identical.
- Special property : In the second group, each station has degree at most , and stations numbered are directly connected by a channel if and only if .
- Special property : In the third group, each station has degree at most .
- Special property : .

There are test points in total, with the following mapping from subtasks to test points:
- Subtask : test points –.
- Subtask : test point .
- Subtask : test points –.
- Subtask : test points –.
- Subtask : test points –.
- Subtask : test points –.
- Subtask : test points –.
- Subtask : test points –.
[Notes]
- It is possible that two groups both contain a channel connecting stations and . In that case, we consider these as two distinct channels.
- In the special properties, “structurally identical” between groups A and B means: if there is a channel between and with user count in group A, then there must also be a channel between and with user count in group B. Whether they are considered identical is independent of the description format and the input order. That is, in two structurally identical groups A and B, the order of channel inputs may differ, and the order of endpoints in each channel’s input may also differ (for a channel connecting with user count in groups A and B, one possible input is for group A and for group B).
Translated by ChatGPT 5
京公网安备 11011102002149号