A - Big Clique Everywhere Editorial /

Time Limit: 4 sec / Memory Limit: 1024 MB

配点 : 600600

問題文

11 から NN までの番号がついた NN 頂点の単純無向グラフ GG が与えられます。 GGMM 本の辺を持ち、ii 本目の辺は頂点 AiA_iBiB_i を結びます。

GG が次の条件を満たすか判定してください。

  • 頂点集合 {1,2,,N}\{1,2,\cdots,N\} のすべての部分集合 XX に対して、XX の部分集合 YY であって YX2|Y|\ge \frac{|X|}{2} かつ YY がクリークを形成するものが存在する。

解くべきテストケースは TT 個あります。

制約

  • 1T1031\le T \le 10^3
  • 1N1051\le N \le 10^5
  • 0M1060 \le M \le 10^6
  • 1Ai,BiN1 \le A_i,B_i \le N
  • 与えられるグラフは自己辺も多重辺も含まない。
  • ひとつの入力の中のテストケースすべてにわたる NN の総和は 10510^5 以下である。
  • ひとつの入力の中のテストケースすべてにわたる MM の総和は 10610^6 以下である。
  • すべての入力値は整数である。

入力

入力は標準入力から以下の形式で与えられる。

TT
case1case_1
case2case_2
\vdots
caseTcase_T

各テストケースは以下の形式で与えられる。

NN MM
A1A_1 B1B_1
A2A_2 B2B_2
\vdots
AMA_M BMB_M

出力

各テストケースについて、GG が条件を満たすなら Yes、そうでないなら No と出力せよ。
Yes または No の出力において、各文字は大文字・小文字のいずれでもよい。


入力例 1Copy

Copy
4
3 3
1 2
1 3
2 3
3 2
1 2
1 3
3 1
1 2
3 0

出力例 1Copy

Copy
Yes
Yes
Yes
No

11 番目のテストケースについて、GG は条件を満たします。 この場合、すべての部分集合 XX がクリークであるため、単に Y=XY=X とできます。

22 番目のテストケースについて、GG は条件を満たします。 例えば、X={2,3}X=\{2,3\} に対しては、Y={2}Y=\{2\} とできます。

44 番目のテストケースについて、GG は条件を満たしません。 X={1,2,3}X=\{1,2,3\} とすると、条件を満たす XX の部分集合 YY はありません。

Score : 600600 points

Problem Statement

You are given a simple undirected graph GG with NN vertices numbered 11 to NN. GG has MM edges and the ii-th edge connects vertices AiA_i and BiB_i.

Check if GG satisfies the following condition:

  • For every subset XX of the vertex set {1,2,,N}\{1,2,\cdots,N\}, there exists a subset YY of XX such that YX2|Y|\ge \frac{|X|}{2} and YY forms a clique.

You have TT testcases to solve.

Constraints

  • 1T1031\le T \le 10^3
  • 1N1051\le N \le 10^5
  • 0M1060 \le M \le 10^6
  • 1Ai,BiN1 \le A_i,B_i \le N
  • The given graph doesn't contain self-loops or multiple edges.
  • The sum of NN across the test cases in a single input is at most 10510^5.
  • The sum of MM across the test cases in a single input is at most 10610^6.
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

TT
case1case_1
case2case_2
\vdots
caseTcase_T

Each test case is given in the following format:

NN MM
A1A_1 B1B_1
A2A_2 B2B_2
\vdots
AMA_M BMB_M

Output

For each test case, if GG satisfies the condition, print Yes, and otherwise print No.
In printing Yes or No, you can output each letter in any case (upper or lower).


Sample Input 1Copy

Copy
4
3 3
1 2
1 3
2 3
3 2
1 2
1 3
3 1
1 2
3 0

Sample Output 1Copy

Copy
Yes
Yes
Yes
No

For the 11-st test case, GG satisfies the condition. In this case, every subset XX is a clique, so we can just let Y=XY=X.

For the 22-nd test case, GG satisfies the condition. For example, for X={2,3}X=\{2,3\}, we can let Y={2}Y=\{2\}.

For the 44-th test case, GG doesn't satisfy the condition. If we let X={1,2,3}X=\{1,2,3\}, no subset YY of XX satisfies the condition.



2025-03-29 (Sat)
12:14:25 +00:00