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

30500번 - Locking Doors 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB74625885.294%

문제

You just started a new job at a shopping mall, and as it goes, you got the shittiest task of all: closing down at night. The mall consists of many rooms (which can be shops, hallways, or other public spaces) with open doors between them that must be closed. You can walk through a door both ways if it is open, but annoyingly, each door can only be locked from one of the two rooms it connects.

Your supervisor already locked the main entrance of the shopping mall, and left you inside with the task to lock all the doors. In order to do so, you may request additional exits to be installed in some of the rooms. If a room has an exit, then you are able to enter or leave the shopping mall through that room.

What is the minimal number of exits you need to request in order for it to be possible to lock all the doors and then leave the building?

입력

The input consists of:

  • One line with two integers $n$ and $m$ (2ドル\leq n \leq 10^5,ドル 1ドル\leq m \leq 10^6$), the number of rooms and doors, respectively.
  • Then follow $m$ lines, each containing two distinct integers $a$ and $b$ (1ドル \leq a,b \leq n,ドル $a \neq b$), indicating a door connecting rooms $a$ and $b$ which can only be locked from room $a$.

You may assume that all ordered pairs $(a,b)$ are distinct and that you can walk from any room in the mall to any other room if all the doors are open.

출력

Output the minimal number of exits that need to be installed.

제한

예제 입력 1

2 1
1 2

예제 출력 1

1

예제 입력 2

3 2
2 1
3 1

예제 출력 2

2

예제 입력 3

5 4
1 2
3 1
4 1
5 1

예제 출력 3

3

예제 입력 4

10 14
1 2
2 1
3 4
3 5
4 6
5 6
6 3
7 8
8 9
9 7
1 8
2 10
4 9
5 10

예제 출력 4

2

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2023 L번

  • 문제를 만든 사람: Jorke de Vlas, Mike de Vries
(追記) (追記ここまで)

출처

대학교 대회

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

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