Elden Ring I——艾尔登法环 I
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
Statement
Timothy has recently become obsessed with a Souls-like game called Elden Ring. The goal is simple: level up, defeat monsters, and ultimately defeat the boss.
Although it's an open world, because the game's director, Hidetaka Miyazaki, likes small-scale maps, one-way doors often appear. These doors require the player to open them in order to connect two locations. For example, a one-way door from A to B cannot be opened from B. Before the door is opened, you can't go from B to A. You need to take another route to A to open the one-way door, and then you can go from B to A. On a normal path, A and B are mutually accessible.
At the beginning of the game, the player is teleported to a node called "Grace." The player can teleport back to "Grace" at any time. The player's goal is to reach a node called "Boss" to defeat the boss. Assume that the distance from one node to the adjacent node is 1. You need to calculate the shortest path from "Grace" to the boss. If the player teleports back to "Grace" or passes through "Grace" again, the path calculation must be restarted.
Input
The first line contains an integer , representing the number of nodes, where each node is numbered ;
The second line contains two integers , representing the number of "Grace" points and the number of boss points ;
The third line contains two integers , representing the number of one-way doors and the number of normal roads ;
The next lines, each containing two integers , indicate that the door from node to is a one-way door, and that it is impossible to go from to until it is opened;
The next lines, each containing two integers , indicate the number of one-way doors from node to . The path from to is a normal path, and nodes and are connected.
Output
Output an integer representing the shortest distance from the "Grace" point to the Boss point.
If the boss point can never be reached, output false
Samples
10
1 10
1 8
4 2
1 2
2 3
3 5
5 6
6 7
7 4
4 10
8 9
3
Notes
For the example shown below, the player can open the one-way door in the following order: $1\rightarrow 2\rightarrow 3\rightarrow 5\rightarrow 6\rightarrow 7\rightarrow 4\rightarrow 2$, then teleport back to the blessing . The distance of 3 is the shortest path.

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