시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 256 MB | 37 | 24 | 21 | 63.636% |
One popular method of controlling the spread of disease are Bubbles. Each person chooses a bubble of other people to associate with and avoids contact with others. Infection in one bubble should not spread to people in other bubbles.
The concept fails, however, when a person belongs to multiple bubbles. For example, a person might have a personal bubble of family and friends and a work bubble of colleagues. In this problem, we will make the following simplifying assumptions:
Given a list of the bubbles that have been infected, determine how many people have been infected.
First line: three integers P, W, N, the number of people in each personal and work bubble and the number of infected bubbles. These numbers satisfy the constraints 1 ≤ P, W ≤ 200, 000 and 0 ≤ N ≤ min(P + W, 10 000). Next N lines: the letter P
or W
, a space, and an integer B, indicating that personal or work bubble number B is infected. When the letter is P
, B satisfies the constraint 0 ≤ B < W. When the letter is W
, B satisfies the constraint 0 ≤ B < P. Each infected bubble is listed only once.
A single integer I, the total number of people infected.
2 3 2 W 1 P 1
4