TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

You are given a simple undirected unweighted graph, consisting of $N$ vertices and $M$ edges.
The $i$-th edge is between vertex $a_ i$ and vertex $b_ i$.

A graph is chordal if it does not have an induced cycle of length four or more.
A perfect elimination ordering is an ordering of the vertices such that for every vertex $v$, $v$ and the neighbors of $v$ that appear after it in the ordering form a clique.
It can be shown that a graph is chordal if and only if it has a perfect elimination ordering.

If the graph is chordal, find a perfect elimination ordering. If there are multiple perfect elimination orderings, print any of them.

If the graph is not chordal, find an induced cycle of length four or more. If there are multiple such cycles, print any of them.

Input Format

$N$ $M$
$a_ 0$ $b_ 0$
$a_ 1$ $b_ 1$
$a_ 2$ $b_ 2$
$\vdots$
$a_ {M - 1}$ $b_ {M - 1}$

Output Format

If the graph is not chordal, output an induced cycle of length four or more in the following format.
NO
$K$
$c_ 0$ $c_ 1$ $\ldots$ $c_ K$

$K$ represents length of the induced cycle.
$c_ i$ is the $i$-th vertex in the cycle.

If the graph is chordal, output a perfect elimination ordering in the following format.
YES
$v_ 0$ $v_ 1$ $\ldots$ $v_ N$

$v_ i$ is the $i$-th vertex in the perfect elimination ordering.

Sample Input 1

4 4
1 3
0 3
1 2
0 1

Sample Output 1

YES
2 0 1 3

Sample Input 2

5 4
0 2
1 3
0 1
3 2

Sample Output 2

NO
4
1 3 2 0

Sample Input 3

10 15
0 1
1 2
2 3
3 4
4 0
5 6
6 7
7 8
8 9
9 5
0 5
1 7
2 9
3 6
4 8

Sample Output 3

NO
5
6 3 2 9 5

Hints

  • $1 \leq N \leq 2 \times 10^ {5}$
  • $0 \leq M \leq 2 \times 10^ {5}$
  • $0 \leq a_ i \lt N$
  • $0 \leq b_ i \lt N$
  • $a_ i \neq b_ i$
  • $\lbrace a_ i, b_ i \rbrace \neq \lbrace a_ j, b_ j \rbrace (i \neq j)$

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 2097152 2097152
1 5000 2097152 2097152
2 5000 2097152 2097152
3 5000 2097152 2097152
4 5000 2097152 2097152
5 5000 2097152 2097152
6 5000 2097152 2097152
7 5000 2097152 2097152
8 5000 2097152 2097152
9 5000 2097152 2097152
10 5000 2097152 2097152
11 5000 2097152 2097152
12 5000 2097152 2097152
13 5000 2097152 2097152
14 5000 2097152 2097152
15 5000 2097152 2097152
16 5000 2097152 2097152
17 5000 2097152 2097152
18 5000 2097152 2097152
19 5000 2097152 2097152
20 5000 2097152 2097152
21 5000 2097152 2097152