luogu#P6918. [ICPC2016 WF] Branch Assignment
[ICPC2016 WF] Branch Assignment
题目描述
The Innovative Consumer Products Company (ICPC) is planning to start a top-secret project. This project consists of subprojects. There will be branches of ICPC involved in this project and ICPC wants to assign each branch to one of the subprojects. In other words, the branches will form disjoint groups, with each group in charge of a subproject.
At the end of each month, each branch will send a message to every other branch in its group (a different message to each branch). ICPC has a particular protocol for its communications. Each branch has a secret key known only to the branch and the ICPC headquarters. Assume branch wants to send a message to branch . Branch encrypts its message with its key . A trusted courier picks up this message from this branch and delivers it to the ICPC headquarters. Headquarters decrypts the message with key and re-encrypts it with key . The courier then delivers this newly encrypted message to branch , which decrypts it with its own key . For security reasons, a courier can carry only one message at a time.
Given a road network and the locations of branches and the headquarters in this network, your task is to determine the minimum total distance that the couriers will need to travel to deliver all the end-of-month messages, over all possible assignments of branches to subprojects.
输入格式
The first line of input contains four integers , , , and , where () is the number of intersections, () is the number of branches, () is the number of subprojects, and () is the number of roads. The intersections are numbered from through . The branches are at intersections through , and the headquarters is at intersection . Each of the next lines contains three integers , , and , indicating a one-way road from intersection to a different intersection () of length (). No ordered pair appears more than once, and from any intersection it is possible to reach every other intersection.
输出格式
Display the minimum total distance that the couriers will need to travel.
题目大意
题目描述
给定一个 个点, 条边的有向强连通图,正整数 满足 。第 个点称为总部。点 向点 发送信息的代价是 。
现将点集 划分为 个不相交的子集 。同一个子集内的点两两之间会互相发送信息。求最小化总代价。
数据范围
,,,边权非负且不大于 。
5 4 2 10
5 2 1
2 5 1
3 5 5
4 5 0
1 5 1
2 3 1
3 2 5
2 4 5
2 1 1
3 4 2
13
5 4 2 10
5 2 1
2 5 1
3 5 5
4 5 10
1 5 1
2 3 1
3 2 5
2 4 5
2 1 1
3 4 2
24
提示
Time limit: 2000 ms, Memory limit: 1048576 kB.
International Collegiate Programming Contest (ACM-ICPC) World Finals 2016