AtCoder Grand Contest 071
C
Orientable as Desired
AtCoder
⌀ 2774
原题
← BD →
翻译中…

Problem Statement

翻译中…

There is a simple connected undirected graph $G$ with $N$ vertices and $M$ edges, where the vertices are labeled $1,2,\dots,N$. The $i$-th edge connects two vertices $u_i$ and $v_i$.

翻译中…

Determine whether there exists a length-$N$ sequence of non-negative integers $X=(X_1,X_2,\dots,X_N)$ that satisfies all of the following conditions:

翻译中…
  • $X_v$ does not exceed the degree of vertex $v$ in $G$ for each $v=1,2,\dots,N$.
  • There is no directed graph obtained by assigning directions to the $M$ edges of $G$ in which, for each $v=1,2,\dots,N$, either the in-degree or the out-degree of $v$ equals $X_v$.
翻译中…

You have $T$ test cases; solve each of them.

翻译中…

Constraints

翻译中…
  • $1 \leq T \leq 10^5$
  • $2 \leq N \leq 2 \times 10^5$
  • $N-1 \leq M \leq 2 \times 10^5$
  • $1 \leq u_i, v_i \leq N$
  • All input values are integers.
  • The graph $G$ given in the input is a simple connected undirected graph.
  • The sum of $N$ over all test cases in each input is at most $2 \times 10^5$.
  • The sum of $M$ over all test cases in each input is at most $2 \times 10^5$.
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

T
\mathrm{case}_1
\vdots
\mathrm{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

翻译中…

Output

翻译中…

Print $T$ lines. The $i$-th line should contain the answer for the $i$-th test case. If there exists an $X$ that satisfies the conditions, print Yes; otherwise, print No.

翻译中…

样例

Input #1
3
4 4
1 2
2 3
3 4
4 1
7 6
3 4
3 6
2 5
1 2
1 3
2 7
15 20
11 13
11 7
12 6
5 2
4 1
15 3
9 8
13 5
8 6
7 5
11 8
12 9
14 1
1 11
6 7
1 3
2 3
3 7
5 12
10 6
Output #1
Yes
No
Yes
In the first test case, for example, $X=(2,2,2,1)$ satisfies the conditions. In the second test case, no sequence $X$ satisfies the conditions.
题目信息
题号
agc071_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。