| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 5 초 | 1024 MB | 74 | 62 | 58 | 85.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:
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.
2 1 1 2
1
3 2 2 1 3 1
2
5 4 1 2 3 1 4 1 5 1
3
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 > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2023 L번