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

16056번 - Plug It In! 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB129624750.000%

문제

Adam just moved into his new apartment and simply placed everything into it at random. This means in particular that he did not put any effort into placing his electronics in a way that each one can have its own electric socket.

Since the cables of his devices have limited reach, not every device can be plugged into every socket without moving it first. As he wants to use as many electronic devices as possible right away without moving stuff around, he now tries to figure out which device to plug into which socket. Luckily the previous owner left behind a plugbar which turns one electric socket into 3.

Can you help Adam figure out how many devices he can power in total?

입력

The input consists of:

  • one line containing three integers m, n and k, where
    • m (1 ≤ m ≤ 1 500) is the number of sockets;
    • n (1 ≤ n ≤ 1 500) is the number of electronic devices;
    • k (0 ≤ k ≤ 75 000) is the number of possible connections from devices to sockets.
  • k lines each containing two integers xi and yi indicating that socket xi can be used to power device yi.

Sockets as well as electronic devices are numbered starting from 1.

The plugbar has no cable, i.e. if it is plugged into a socket it simply triples it.

출력

Output one line containing the total number of electrical devices Adam can power.

제한

예제 입력 1

3 6 8
1 1
1 2
1 3
2 3
2 4
3 4
3 5
3 6

예제 출력 1

5

예제 입력 2

4 5 11
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
4 4
4 5

예제 출력 2

5

예제 입력 3

3 5 7
1 1
1 2
2 2
2 3
2 4
3 4
3 5

예제 출력 3

5

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2017 F번

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

출처

대학교 대회

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

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