Logo
(追記) (追記ここまで)

21841번 - Bubbles 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB105484548.387%

문제

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:

  • Each personal bubble contains the same number of people, P.
  • Each work bubble contains the same number of people, W.
  • Each person is in exactly one personal bubble and one work bubble.
  • Each pair of personal bubble and work bubble has exactly one person in common.

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.

제한

예제 입력 1

2 3 2
W 1
P 1

예제 출력 1

4

힌트

출처

Contest > Waterloo's local Programming Contests > 6 February, 2021 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /