#P8403. [CCC 2022 J4] Good Groups
[CCC 2022 J4] Good Groups
Background
Please note: this problem is a simplified version of CCO 2022 S2 Good Groups.
Admin note: it seems it is not simplified.
Problem Description
A class will be divided into groups, with three students in each group. This grouping may break two kinds of rules:
- Some students must be in the same group.
- Some students must not be in the same group.
Now the principal asks you how many rules in total are violated by the students.
Input Format
The first line contains an integer . The next lines each contain two student names , meaning these two students must be assigned to the same group.
Next is an integer . The next lines each contain two student names , meaning these two students must not be in the same group.
Next is an integer . The next lines each contain three student names , meaning these three students are currently in the same group.
Output Format
Output one integer, the total number of rules violated by the students.
1
ELODIE CHI
0
2
DWAYNE BEN ANJALI
CHI FRANCOIS ELODIE
0
3
A B
G L
J K
2
D F
D G
4
A C G
B D F
E H I
J K L
3
Hint
Explanation for Sample 2:
- and must be in the same group, and this rule is violated.
- and must be in the same group, and this rule is violated.
- and must be in the same group, and this rule is not violated.
- and must not be in the same group, and this rule is violated.
- and must not be in the same group, and this rule is not violated.
Among these rules, are violated, so the output is .
Constraints:
For of the testdata: , , .
For another of the testdata: , , .
For of the testdata: , , .
Translated by ChatGPT 5