#P10129. 「Daily OI Round 3」City Planning

    ID: 11329 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>网络流洛谷原创O2优化最小割线性规划

「Daily OI Round 3」City Planning

Background

As long as you do not lose your nobility, the whole world will open up to you.

Problem Description

The administrators of Provence-Alpes-Côte d'Azur have run into big trouble. They invited you to solve a city planning problem.

There are tt administrators in total, and there are nn towns in this region. In town ii, there are kik_i villages, connected by pip_i roads. The jj-th road bidirectionally connects villages ui,ju_{i,j} and vi,jv_{i,j} in town ii. The person in charge of this road is administrator wi,jw_{i,j}, and the passenger flow is zi,jz_{i,j}.

To maintain unity within the administrator group, each person can manage at most 11 road in the same town.

Now, the villages and the roads between villages in these towns have all been damaged, and the administrators urgently want to restore transportation inside these towns. Between the towns, there are mm high-speed railways. Each railway connects two towns u,vu, v. Also, for aesthetic design reasons, the nn towns and the mm high-speed railways form a bipartite graph.

For each town ii, you need to help the administrator group choose a parameter ci(1ciki)c_i(1 \le c_i \le k_i) and repair some villages. All villages with indices in 1ci1 \sim c_i will be repaired. If both endpoints of a road are repaired, then the road will be repaired automatically. Therefore, in town ii, a cost of bi,cib_{i,c_i} will be incurred.

For administrator ii, if there exist two roads managed by them in different towns that are both not repaired, and the towns these two roads belong to are directly connected by a high-speed railway, then you need to pay the product of the passenger flows of these two roads to compensate for the loss, so that administrator ii will be satisfied. (For any pair of roads that satisfies the above conditions, you must compensate for the loss, not just compensate for one pair per administrator.)

To make all members of the administrator group satisfied and ensure that the plan meets the requirements of the problem (i.e., 1ciki1 \le c_i \le k_i), you need to compute in advance the minimum amount of money you have to pay to deal with these administrators' demands.

Input Format

The first line contains three integers n,m,tn, m, t, representing the number of towns, the number of high-speed railways between towns, and the number of administrators.

The next mm lines each contain two integers x,yx, y, indicating that this high-speed railway connects towns xx and yy.

Then follow nn groups of input. For the ii-th group, the format is as follows:

The first line contains two integers ki,pik_i, p_i, indicating that town ii has kik_i villages and pip_i roads.

The second line contains kik_i integers. The jj-th integer represents the cost bi,jb_{i,j} when c=jc = j.

The next pip_i lines each contain four integers ui,j,vi,j,wi,j,zi,ju_{i,j}, v_{i,j}, w_{i,j}, z_{i,j}, indicating that there is an edge connecting the ui,ju_{i,j}-th village and the vi,jv_{i,j}-th village in town ii, the person in charge is administrator wi,jw_{i,j}, and the passenger flow is zi,jz_{i,j}.

Output Format

Output one integer in one line, representing the minimum total cost to make all administrators satisfied.

2 2 3
2 1
2 1
1 3
3
1 1 2 3
1 1 1 1
1 1 3 3
2 0
7 6
9
3 1 3
1 2
3 2
1 2 3
1 2 1 3
2 3 2 2
2 2
1 100
1 1 1 3
1 2 2 1
5 1
5 0 5 5 5
4 5 1 3
4
5 6 5
4 3
3 5
1 2
2 1
3 4
3 5
2 0
37 44
4 2
33 2 43 49
3 1 3 6
3 4 4 6
6 4
4 23 0 9 35 22
3 4 2 7
3 4 5 3
2 1 3 2
4 4 4 10
3 2
14 41 35
2 2 4 1
3 3 2 5
3 5
27 39 9
3 3 2 1
3 2 3 3
2 1 1 5
2 1 5 3
1 2 4 8
71

Hint

Sample Explanation #1

We can choose c1=1,c2=2c_1 = 1, c_2 = 2. Then the cost is b1,c1+b2,c2=3+6=9b_{1,c_1} + b_{2,c_2} = 3 + 6 = 9, and there is no administrator that you need to compensate.

Sample Explanation #2

We can choose c1=1,c2=1,c3=2c_1 = 1, c_2 = 1, c_3 = 2. Then the cost is b1,c1+b2,c2+b3,c3=1+1=2b_{1,c_1} + b_{2,c_2} + b_{3,c_3} = 1 + 1 = 2. However, administrator 22's road 232 \to 3 in town 11 cannot possibly be repaired, and their road 121 \to 2 in town 22 cannot possibly be repaired either, so you need to pay 2×1=22 \times 1 = 2 to compensate administrator 22. The total cost is 44.

You do not need to compensate administrator 11, even though they have one road in town 11 and one road in town 33\, that cannot be repaired, because towns 11 and 33 are not connected by a high-speed railway, so you do not need to pay extra money for this.

Constraints

For all data, it is guaranteed that: 1n501 \le n \le 50, 1ki1001 \le k_i \le 100, 0pit0 \le p_i \le t, 0m5000 \le m \le 500, 1t501 \le t \le 50, 1x,yn1 \le x, y \le n, xyx \ne y, 0bi,j1090 \le b_{i,j} \le 10^9, 1ui,j,vi,jki1 \le u_{i,j}, v_{i,j} \le k_i, 1wi,jt1 \le w_{i,j} \le t, 1zi,j1041 \le z_{i,j} \le 10^4.

The graph formed by the nn towns and the mm high-speed railways is a bipartite graph. For each administrator, the number of roads they manage within the same village does not exceed 11.

There may be multiple different high-speed railways connecting the same pair of towns, and there will be no railway that connects a town to itself. However, within a town, villages may have roads that connect to themselves, and there may also be multiple different roads connecting the same pair of villages.

Translated by ChatGPT 5