QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 128 MB Total points: 100

#12682. Congcong and Coco

Statistics

In a magical forest, there lives a clever little cat named Congcong and a cute little mouse named Keke. Although Cinderella is very fond of both of them, Congcong is, after all, a cat, and Keke is, after all, a mouse. What remains unchanged is that Congcong spends all day thinking about eating Keke.

One day, Congcong accidentally obtained a very useful machine, said to be a GPS, which can accurately locate Keke. With this machine, it would be easy for Congcong to catch Keke. So, Congcong prepared to set off immediately to find Keke. Poor Keke, unaware that disaster was imminent, was still playing happily in the forest. The little rabbit Guai-Guai heard about this and immediately reported it to Cinderella. Cinderella decided to stop Congcong as soon as possible to save Keke, but she did not know if there was enough time left.

The entire forest can be considered an undirected graph with $N$ beautiful locations, numbered from $1$ to $N$. The animals only rest and play at these locations. There are some paths connecting the locations.

When Congcong obtained the GPS, Keke was at location $M$ ($M \le N$). In each subsequent time unit, Keke will choose to go to one of the adjacent locations (there may be several) or stay at the current location. The probability of going to any of these places is equal. Suppose there are $P$ locations adjacent to location $M$, which are location $R$, location $S$, ..., location $Q$. If Keke is at location $M$ at time $T$, then at time $T+1$, Keke has a $\frac{1}{P+1}$ probability of being at location $R$, a $\frac{1}{P+1}$ probability of being at location $S$, ..., a $\frac{1}{P+1}$ probability of being at location $Q$, and a $\frac{1}{P+1}$ probability of staying at location $M$.

We know that Congcong is very clever. Therefore, when she is at location $C$, she will choose a location that is closer to Keke. If there are multiple such locations, she will choose the one with the smallest index. Because Congcong wants to eat Keke so much, if she has not caught Keke after the first step, she can move one more step closer to Keke within the same time unit.

In each time unit, assume Congcong moves first, and then Keke moves. At any moment, if Congcong and Keke are at the same location, poor Keke is eaten.

Cinderella wants to know, on average, how many steps it will take for Congcong to eat Keke. You need to help Cinderella find the answer as quickly as possible.

Input

The first line contains two integers $N$ and $E$, separated by a space, representing the number of locations in the forest and the number of paths connecting adjacent locations, respectively.

The second line contains two integers $C$ and $M$, separated by a space, representing the initial locations of Congcong and Keke, respectively.

The next $E$ lines each contain two integers $A_i$ and $B_i$, representing a path between location $A_i$ and location $B_i$.

All paths are undirected, meaning if one can go from $A$ to $B$, one can also go from $B$ to $A$.

The input guarantees that there is at most one direct path between any two locations, and there is a path (direct or indirect) between Congcong and Keke.

Output

Output a single real number, rounded to three decimal places, representing the average number of time units after which Congcong will eat Keke.

Examples

Input 1

4 3
1 2
1 2
2 3
3 4

Output 1

1.500

Input 2

9 9
9 3
1 2
2 3
3 4
4 5
3 6
4 6
4 7
7 8
8 9

Output 2

2.167

Note

The forest structure

Constraints

  • For all data, $1 \le N, E \le 1000$.
  • For 50% of the data, $1 \le N \le 50$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.