#P8215. [THUPC 2022 初赛] 分组作业
[THUPC 2022 初赛] 分组作业
Problem Description
The teacher assigned a group project. Before that, the teacher had divided the students in the class into groups, with two people in each group. Student and student are in one group, student and student are in one group, , and student and student are in one group.
The teacher lets each team arrange the division of work by themselves. Whether they will cooperate becomes a big problem, so everyone decides to determine it by voting. First, each person decides whether they are willing to cooperate with their teammate. Different people have different willingness to cooperate due to their own reasons and the reasons related to their assigned teammate. For student , choosing “willing” produces dissatisfaction , and choosing “unwilling” produces dissatisfaction .
If both teammates choose “willing”, then depending on the actual situation they may cooperate or may not cooperate. However, if one teammate chooses “unwilling”, then they can only not cooperate.
Among the students, there are also directed “like” relationships. Each relationship is of the form “ likes ”. In such a relationship, if does not cooperate with their teammate and chooses “willing”, then will feel a bit upset and produce dissatisfaction ; if voted “unwilling” but successfully cooperates with their teammate, then will feel envy and produce dissatisfaction . (Since this setting would become strange when and are in the same group, the problem guarantees that this will not happen.) Here denotes the -th relationship.
If a student chooses “willing” but their teammate chooses “unwilling”, then they will have dissatisfaction because of their teammate.
Find the minimum possible total dissatisfaction over all cases.
Input Format
The first line contains two integers .
The next lines each contain three integers .
The next lines each contain four positive integers .
Output Format
Output one integer in one line, representing the answer.
2 1
8 6 7
5 2 8
7 1 5
6 5 8
1 4 4 3
14
Hint
Constraints
It is guaranteed that , , and .
Translated by ChatGPT 5