No.1563 Same Degree
タグ : / 解いたユーザー数 138
作問者 :
maguro
/ テスター :
PCTprobability
Problem Statement
You are given a simple graph $G$ with $N$ vertices and $M$ edges. The $i\ (1 \leq i \leq M)$-th edge connects vertex $u_i$ and vertex $v_i$.
Does $G$ have a pair of vertices $(a,b)\ (a \neq b)$ with equal degrees?
You are given $T$ cases; find the answer for each of them.
Input
$T$ $case_1$ $case_2$ $\vdots$ $case_T$
Each case is given in the following format.
$N\ M$ $u_1\ v_1$ $u_2\ v_2$ $\vdots$ $u_M\ v_M$
- All inputs are integers.
- $1 \leq T \leq 10^4$
- $1 \leq N \leq 10^5$
- $0 \leq M \leq 2 \times 10^5$
- $1 \leq u_i,v_i \leq N$
- $u_i \neq v_i$
- $(u_i,v_i) \neq (u_j,v_j)\ (i \neq j)$
- $(u_i,v_i) \neq (v_j,u_j)\ (i \neq j)$
- In $1$ test case, the sum of $N$ does not exceed $10^5$.
- In $1$ test case, the sum of $M$ does not exceed $2 \times 10^5$.
Output
Output $T$ lines.
On the $i\ (1 \leq i \leq N)$-th line, for $case_i$, print Yes if a pair of vertices with equal degrees exists, and No otherwise.
Print a newline at the end.
Sample
Sample 1
Input
2 5 5 1 3 2 5 5 3 4 2 2 1 2 1 1 2
Output
Yes Yes
In the $1$st case, for example, vertex $1$ and vertex $3$ both have degree $2$.
In the $2$nd case, vertex $1$ and vertex $2$ both have degree $1$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。