| UTPC Contest 3-11-26 (Beginner) |
|---|
| Finished |
Innersloth is developing a new map for Among Us and has invited you to be a beta tester! This new map features an experimental venting system. Instead of the traditional interconnected vent networks, these new vents are one-way. Once an Impostor enters a vent in one room, they are dropped off in a specific destination room and cannot go back through the same vent.
You are playing as the Impostor and start the game in Room $$$1$$$. Given the layout of the rooms and vents, find the number of distinct rooms (including where you start) that you can visit by using some sequence of vents.
The first line of input will contain $$$2$$$ space-separated integers $$$n$$$ and $$$m$$$ ($$$1 \le n \le 2 \cdot 10^5, 0 \le m \le 2 \cdot 10^5$$$) — the number of rooms on the map and the number of one-way vents, respectively.
The next $$$m$$$ lines of input will each contain $$$2$$$ space-separated integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \le u_i, v_i \le n$$$) — representing a one-way vent that allows travel from Room $$$u_i$$$ to Room $$$v_i$$$.
Output a single integer — the total number of distinct rooms that are reachable from Room $$$1$$$.
6 51 22 31 45 63 2
4
Explanation: Starting from Room 1, you can use vents to travel to Room 2 and Room 4. From Room 2, you can travel to Room 3. From Room 3, you can travel back to Room 2. There is no sequence of vents that leads to Room 5 or Room 6 from Room 1. Therefore, you can reach 4 distinct rooms: 1, 2, 3, and 4.
| Name |
|---|


