ICPC NEERC 2010 K - Graph Oddity
View as PDFYou are given a connected undirected graph with an odd number of
vertices. The degree of the vertex, by definition, is the number of
edges incident to it. In the given graph the degree of each vertex does
not exceed an odd number . Your task is to color the vertices of this
graph into at most 
 distinct colors, so that the colors of any two
adjacent vertices are distinct.
The pictures below show two graphs. The first one has  vertices and the
second one has 
 vertices. In both graphs degrees of the vertices do not
exceed 
 and the vertices are colored into at most 
 different colors
marked as
'
',
'
' and
'
'.
Input Specification
The first line of the input contains two integer numbers  and 
,
where 
 is the number of vertices in the graph 
 is odd
,
 is the number of edges in the graph 
.
The following 
 lines describe edges of the graph, each edge is
described by two integers 
 
 -
the vertex numbers connected by this edge. Each edge
is listed at most once. The graph in the input is connected, so there is
a path between any pair of vertices.
Output Specification
On the first line of the output write a single integer number  - the
minimal odd integer number, such that the degree of any vertex does not
exceed 
. Then write 
 lines with one integer number 
 
on a line that denotes the color of 
-th vertex.
The colors of any two adjacent vertices must be different. If the graph has multiple different colorings, print any of them. At least one such coloring always exists.
Sample Input 1
3 2
1 3
3 2
Sample Output 1
3
1
1
2
Sample Input 2
7 8
1 4
4 2
2 6
6 3
3 7
4 5
5 6
5 2
Sample Output 2
3
1
1
1
2
3
2
2
Comments