No.2948 move move rotti
タグ : / 解いたユーザー数 92
作問者 :
rotti_coder
/ テスター :
Michirakara
aplysiaSheep
t9unkubj
Problem Statement
There are $N$ parks in the town where Rotti lives.
The parks are numbered from $1$ to $N$.
There are also $M$ roads, and road $i$ bidirectionally connects park $U_i$ and park $V_i$.
Rotti has $K$ friends. For each $i$, friend $i$ is at park $X_i$.
From now on, the following action is performed $0$ or more times.
Rotti wants to gather with everyone at one park and play. Determine whether all people can gather at the same vertex with $0$ or more actions.
Constraints
- $1\leq N\leq 15$
- $0\leq M\leq N(N-1)/2$
- $1\leq U_i < V_i \leq N$
- $2\leq K\leq N$
- $1\leq X_i\leq N$
Input
The input is given from standard input in the following format.
$N$ $M$ $K$ $X_1$ $X_2$ $X_3$ $\dots$ $X_K$ $U_1$ $V_1$ $U_2$ $V_2$ $\vdots$ $U_M$ $V_M$
Output
If all people can gather at the same vertex, print Yes; otherwise, print No.
Sample Input and Output
Sample 1
Input
3 2 2 1 3 1 2 2 3
Output
Yes
On the $1$st action, friend $1$ and friend $2$ should move to park $2$.
Sample 2
Input
5 5 4 2 2 2 2 1 2 2 4 3 5 4 5 1 5
Output
Yes
All friends may be at the same park from the beginning.
Sample 3
Input
4 4 2 1 2 1 2 2 3 3 4 1 4
Output
No
The $2$ people cannot meet.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。