Elden Ring II——艾尔登法环 II
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Statement
In the Elden Ring, there's a well-known landmark called the "Royal City Sewers." This complex structure is a must-see for many experienced soul Ass and novice tarnished. It consists of rooms and a number of two-way corridors. Each room has up to three doors, and corridors lead from behind the room doors to other rooms. All corridors in each room lead to different rooms. The entire sewer is interconnected, meaning you can travel between any two rooms, though you may need to pass through other rooms.
You need help labeling the doors to make exploration easier. The idea is that if a room has doors leading to other rooms, these doors will be labeled , and then all players will follow a simple procedure. If they are in room at the start of their exploration, they will choose the door labeled 1 and go through the corresponding corridor. If they are in room and enter from the corridor through a door labeled , they will choose the door labeled with the next number (i.e., if , or 1 if ) and go through the corresponding corridor.
Now that we have the labeling set, you need to find the number of different corridors that the players will go through if they start their exploration from each room, assuming they follow the rules and walk long enough.
Input
The first line contains an integer (), which represents the number of rooms in the sewers.
The next lines contain descriptions of all the corridors, with line describing the corridor connecting room to the others. It begins with an integer (), indicating the number of doors in that room. Next are integers , giving the room numbers and if ) to which these doors lead, in the order of their assigned numbers.
Note that all corridors are bidirectional, so if there is a door from room to room , then there is also a door from room to room .
Output
Output lines, where line contains the number of different corridors the player will visit if they start in room .
Samples
6
3 4 2 3
3 5 1 3
3 6 1 2
1 1
1 2
1 3
5
4
5
5
4
5
Notes
The figure below shows the player's path starting from node 1. The numbers marked on the dark blue and light blue arrows indicate the player's path in step . This shows that the player passes through five different corridors.

2025 JSUT Collegiate Programming Contest 江苏理工学院新生赛-同步赛
- 状态
- 已结束
- 规则
- ACM/ICPC
- 题目
- 15
- 开始于
- 2025-11-8 12:00
- 结束于
- 2025-11-8 17:00
- 持续时间
- 5 小时
- 主持人
- 参赛人数
- 15