K-Graph Oddity
InterviewTime limit1sMemory limit128 MB
Compute the maximum vertex degree in a graph and output the smallest odd integer greater than or equal to it.
- Level
Easy2 of 10
- Topics
- Graph, Implementation, Math
- Solved
- No attempts yet
Problem
You are given a connected undirected graph with an odd number of vertices. The degree of a vertex is the number of edges incident to it.
It is a well-known fact that such a graph can always be properly colored — that is, every vertex can be assigned a color so that no two adjacent vertices share the same color — using at most colors, where is the smallest odd integer that is greater than or equal to the maximum degree of the graph.
Given the graph, determine this value .
Input
The first line contains two integers and : the number of vertices (, is odd) and the number of edges ().
Each of the next lines contains two integers and (, ) describing an edge between vertices and . Each edge is listed at most once. The graph is connected, so there is a path between every pair of vertices.
Output
Output a single integer — the smallest odd integer such that the degree of every vertex does not exceed (equivalently, the smallest odd integer that is greater than or equal to the maximum vertex degree).