QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 2048 MB Total points: 100 Hackable ✓

#21755. Chordal Graph Recognition

Statistics

Given an undirected graph with $N$ vertices and $M$ edges, determine whether it is a chordal graph.

If it is a chordal graph, you must provide any perfect elimination ordering. If it is not a chordal graph, you must provide a cycle of length at least $4$ that does not contain a chord.

Input

The first line contains two integers $N$ and $M$.

The next $M$ lines each contain two integers $x, y$, describing an edge. It is guaranteed that there are no multiple edges or self-loops in the graph.

Output

If the given graph is not a chordal graph:

  • Output a line containing NO.
  • The next line contains an integer $K$, representing the length of the cycle you found.
  • The next line contains $K$ integers $v_0, v_1, \cdots, v_{K-1}$, describing your cycle.

If the given graph is a chordal graph:

  • Output a line containing YES.
  • The next line contains $N$ integers $u_0, u_1, \cdots, u_{N-1}$, describing a perfect elimination ordering.

If there are multiple valid solutions, you may output any one of them.

Constraints

For all data, $1 \leq N \leq 2 \times 10^5$, $1 \leq M \leq 2 \times 10^5$, $0 \leq x, y < N$, $x \ne y$. The graph contains no multiple edges or self-loops.

Examples

Input 1

4 4
1 3
0 3
1 2
0 1

Output 1

YES
2 0 1 3

Input 2

5 4
0 2
1 3
0 1
3 2

Output 2

NO
4
1 3 2 0

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

Output 3

NO
5
6 3 2 9 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.