아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

“Even” Division

시간 제한4초메모리 제한1024 MB

요약
연결된 짝수 개의 정점을 가진 그래프를 정점 수가 짝수인 연결 부분그래프들로 최대한 나누어 출력한다.
난이도

보통10점 중 7점

유형
DFS, 트리, 그리디, 그래프
정답자
아직 제출이 없습니다

문제

If you talk about an even division in the usual sense of the words, it means dividing a thing equally. Today, you need to think about something different. A graph is to be divided into subgraphs with their numbers of nodes being even, that is, multiples of two.

You are given an undirected connected graph with even number of nodes. The given graph is to be divided into its subgraphs so that all the subgraphs are connected and with even number of nodes, until no further such division is possible. Figure I.1 illustrates an example. The original graph of 88 nodes is divided into subgraphs with 44, 22, and 22 nodes. All of them have even numbers of nodes.

Figure I.1. Example of a division (Sample Input/Output 1)

To put it mathematically, an even division of a graph is the set of subsets V_1V\_1, …\dots, V_kV\_k of the graph nodes satisfying the following conditions.

  1. V_1∪⋯∪V_kV\_1 ∪ \cdots ∪ V\_k is the set of all the nodes of the input graph, and V_i∩V_j=∅V\_i ∩ V\_j = ∅ if i≠ji \ne j.
  2. Each V_iV\_i is non-empty, and has an even number of elements.
  3. Each V_iV\_i induces a connected subgraph. In other words, any nodes in V_iV\_i are reachable from each other by using only the edges of the input graph connecting two nodes in V_iV\_i.
  4. There is no further division. For any U_1∪U_2=V_iU\_1 ∪ U\_2 = V\_i, the division obtained by replacing V_iV\_i with the two sets, U_1U\_1 and U_2U\_2, does not satisfy either of the conditions 1, 2, or 3.

Your task is to find an even division of the given graph.

입력

The input consists of a single test case of the following format.

\begin{align\*}& n \\, m \\\ & x\_1 \\, y\_1 \\\ & \vdots \\\ & x\_m \\, y\_m \end{align\*}

The first line consists of two integers nn and mm. The first integer nn (2≤n≤1052 ≤ n ≤ 10^5) is an even number representing the number of the nodes of the graph to be divided. The second integer mm (n−1≤m≤105n - 1 ≤ m ≤ 10^5) is the number of the edges of the graph.

The nodes of the graph are numbered from 00 to n−1n - 1.

The subsequent mm lines represent the edges of the graph. A line x_ix\_i y_iy\_i (0≤x_i<y_i<n0 ≤ x\_i < y\_i < n) means that there is an edge connecting the two nodes x_ix\_i and y_iy\_i. There are no duplicated edges. The input graph is guaranteed to be connected.

출력

If there exists an even division of the node set of the given graph into subsets V_1V\_1, …\dots, V_kV\_k, print kk in the first line of the output. The next kk lines should describe the subsets V_1V\_1, …\dots, V_kV\_k. The order of the subsets does not matter. The ii-th of them should begin with the size of V_iV\_i, followed by the node numbers of the elements of V_iV\_i, separated by a space. The order of the node numbers does not matter either.

If there are multiple even divisions, any of them are acceptable.

힌트

In the Sample 2, the singleton set of the set of the nodes of the original graph is already an even division.

예제2

  1. 예제 1

    입력
    8 9
    0 1
    1 2
    2 3
    0 4
    1 6
    3 7
    4 5
    5 6
    6 7
    
    예상 출력
    3
    2 3 7
    2 4 5
    4 0 1 2 6
    
  2. 예제 2

    입력
    2 1
    0 1
    
    예상 출력
    1
    2 0 1