#P4833. Maximum Domain Partition

    ID: 18077 Type: Default 1000ms 256MiB

Maximum Domain Partition

Maximum Domain Partition

In a divided world, there are n regions (vertices) with some pairs connected by edges. Two opposing sides, Satyania and the Dogs, have divided these regions into domains. Satyania chooses some domains and the Dogs choose the complementary set. Both groups insist on the following connectivity properties:

  1. Within the domains a side controls (for example, Satyania’s domains), any two regions that lie in two different domains must be directly connected by an edge.
  2. For any region in one of Satyania’s domains and any region in any of the Dog’s domains, there is an edge connecting them.

It turns out that these conditions force the entire graph on n vertices to behave as a complete multipartite graph, where the "parts" (or domains) are groups of regions which might have missing edges within them, but every pair of regions in different parts is adjacent.

In fact, note that if two regions are not connected by an edge, they must lie in the same domain. Therefore, the unique finest (i.e. maximum) partition satisfying the above condition is given by the connected components of the complement graph of the given graph. (Here, the complement of a graph on n vertices has an edge between two distinct vertices if and only if the original graph does not have that edge.)

Your task is: Given the graph describing the original connections among the regions, find the maximum number of domains (which is the number of connected components in the complement graph) and determine how many regions each domain contains. Output the count of domains and a sorted (in non‐decreasing order) list of the sizes of these domains.

inputFormat

The first line contains two integers, n and m, where n is the number of regions and m is the number of edges in the graph.

Each of the next m lines contains two integers u and v (1 ≤ u, v ≤ n), indicating that there is an undirected edge between region u and region v.

outputFormat

On the first line print an integer k – the maximum number of domains. On the second line print k space-separated integers in non-decreasing order, where each integer represents the number of regions in one domain.

sample

4 3
1 2
1 3
1 4
2

1 3

</p>