시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 1024 MB | 96 | 45 | 36 | 54.545% |
A class has been divided into groups of three. This division into groups might violate two types of constraints: some students must work together in the same group, and some students must work in separate groups.
Your job is to determine how many of the constraints are violated.
The first line will contain an integer X with X ≥ 0. The next X lines will each consist of two different names, separated by a single space. These two students must be in the same group.
The next line will contain an integer Y with Y ≥ 0. The next Y lines will each consist of two different names, separated by a single space. These two students must not be in the same group.
Among these X + Y lines representing constraints, each possible pair of students appears at most once.
The next line will contain an integer G with G ≥ 1. The last G lines will each consist of three different names, separated by single spaces. These three students have been placed in the same group.
Each name will consist of between 1 and 10 uppercase letters. No two students will have the same name and each name appearing in a constraint will appear in exactly one of the G groups.
Output an integer between 0 and X +Y which is the number of constraints that are violated.
번호 | 배점 | 제한 |
---|---|---|
1 | 3 | G ≤ 50, X ≤ 50, Y = 0 |
2 | 5 | G ≤ 50, X ≤ 50, Y ≤ 50 |
3 | 7 |
G ≤ 100 000, X ≤ 100 000, Y ≤ 100 000 |
1 ELODIE CHI 0 2 DWAYNE BEN ANJALI CHI FRANCOIS ELODIE
0
There is only one constraint and it is not violated: ELODIE and CHI are in the same group.
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
The first constraint is that A and B must be in the same group. This is violated.
The second constraint is that G and L must be in the same group. This is violated.
The third constraint is that J and K must be in the same group. This is not violated.
The fourth constraint is that D and F must not be in the same group. This is violated.
The fifth constraint is that D and G must not be in the same group. This is not violated.
Of the five constraints, three are violated.
Olympiad > Canadian Computing Competition & Olympiad > 2022 > CCC 2022 Junior Division 4번
Olympiad > Canadian Computing Competition & Olympiad > 2022 > CCC 2022 Senior Division 2번