| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 2048 MB | 2 | 2 | 2 | 100.000% |
You are in a forest. In this forest there is also a pair of elks - a cow (an adult female) and her calf (child). As most people know, it is dangerous to get between a cow and her calf, but it is not always clear how to avoid it.
We model our forest as consisting of $N$ locations, and $M$ direct connections between these locations. These connections can be travelled in either direction. The locations are numbered $0$ to $N-1$ and connections are numbered $0$ to $M-1$.
We define a path from the cow to the calf as a series of locations, $p_0, p_1, p_2, \ldots , p_k$ such that:
Clearly, any location that is on any such path is a dangerous place to be, as the cow could consider you to be between her and the calf. Your task is to find all the safe locations - that is, the locations that are not on any such path.
The first line contains four integers, $N, M, A, B$. $N$ and $M$ are the number of locations and direct connections respectively, while $A$ and $B$ are the current locations of the cow and the calf respectively.
The following $M$ lines, numbered from $0$ to $M-1$, each describe one of the $M$ connections. The $i$th of these line contains two integers $U_i$ and $V_i$, indicating that $i$th connection is between locations $U_i$ and $V_i$.
The first line of output should contain a single integer $S$, the number of locations in the forest where it is safe to be.
The next $S$ lines of output should be a list of all the safe locations, one location per line, in increasing numerical order.
| 번호 | 배점 | 제한 |
|---|---|---|
| 1 | 10 | $N \le 10$, $M \le 45$ |
| 2 | 20 | $M = N-1$ and the graph is connected. |
| 3 | 30 | $N \le 200$, $M \le 500$ |
| 4 | 40 | No additional constraints. |
9 10 0 7 1 0 2 0 0 3 5 4 4 3 4 6 3 6 6 7 7 3 7 8
4 1 2 5 8
8 8 2 3 0 1 0 2 1 2 2 3 3 4 3 5 4 5 6 7
2 6 7