포럼
문제 ICPC00356

L. Locking Doors

설명

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
예제 2
입력
3 2
2 1
3 1
출력
2
예제 3
입력
5 4
1 2
3 1
4 1
5 1
출력
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
출력
2
문제 정보

생성자가 기록되지 않았습니다.

출처 ICPC BAPC 2023

평가 및 의견

L. Locking Doors

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 1 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

L. Locking Doors

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8