Codeforces Round 120 (Div. 2)
E
Counter Attack
Codeforces
2100
原题
← D→
翻译中…

Berland has managed to repel the flatlanders' attack and is now starting the counter attack.

翻译中…

Flatland has $*n*$ cities, numbered from $1$ to $*n*$, and some pairs of them are connected by bidirectional roads. The Flatlandian maps show roads between cities if and only if there is in fact no road between this pair of cities (we do not know whether is it a clever spy-proof strategy or just saving ink). In other words, if two cities are connected by a road on a flatland map, then there is in fact no road between them. The opposite situation is also true: if two cities are not connected by a road on a flatland map, then in fact, there is a road between them.

翻译中…

The berlanders got hold of a flatland map. Now Vasya the Corporal is commissioned by General Touristov to find all such groups of flatland cities, that in each group of cities you can get from any city to any other one, moving along the actual roads. Also the cities from different groups are unreachable from each other, moving along the actual roads. Indeed, destroying such groups one by one is much easier than surrounding all Flatland at once!

翻译中…

Help the corporal complete this task and finally become a sergeant! Don't forget that a flatland map shows a road between cities if and only if there is in fact no road between them.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*n*$ and $*m*$ $(1 ≤ *n* ≤ 5·10^{5}, 0 ≤ *m* ≤ 10^{6})$ — the number of cities and the number of roads marked on the flatland map, correspondingly.

翻译中…

Next $*m*$ lines contain descriptions of the cities on the map. The $*i*$-th line contains two integers $*a*_{*i*}$ and $*b*_{*i*}$ $(1 ≤ *a*_{*i*}, *b*_{*i*} ≤ *n*, *a*_{*i*} ≠ *b*_{*i*})$ — the numbers of cities that are connected by the $*i*$-th road on the flatland map.

翻译中…

It is guaranteed that each pair of cities occurs in the input no more than once.

翻译中…

Output

翻译中…

On the first line print number $*k*$ — the number of groups of cities in Flatland, such that in each group you can get from any city to any other one by flatland roads. At the same time, the cities from different groups should be unreachable by flatland roads.

翻译中…

On each of the following $*k*$ lines first print $*t*_{*i*}$ $(1 ≤ *t*_{*i*} ≤ *n*)$ — the number of vertexes in the $*i*$-th group. Then print space-separated numbers of cities in the $*i*$-th group.

翻译中…

The order of printing groups and the order of printing numbers in the groups does not matter. The total sum $*t*_{*i*}$ for all $*k*$ groups must equal $*n*$.

翻译中…

Note

翻译中…

In the first sample there are roads only between pairs of cities 1-4 and 2-3.

翻译中…

In the second sample there is no road between cities 1 and 2, but still you can get from one city to the other one through city number 3.

翻译中…

样例

Input #1
4 4
1 2
1 3
4 2
4 3
Output #1
2
2 1 4
2 2 3
InputCopy OutputCopy
Input #2
3 1
1 2
Output #2
1
3 1 2 3
InputCopy OutputCopy
题目信息
题号
190E
时间限制
3 s
内存限制
256 MB
标签
数据结构
并查集
图论
哈希
排序

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