#K70967. Bipartite Graph Check

    ID: 33426 Type: Default 1000ms 256MiB

Bipartite Graph Check

Bipartite Graph Check

You are given an undirected graph. Your task is to determine whether the graph is bipartite. A graph is bipartite if the set of vertices can be partitioned into two disjoint sets such that no two vertices in the same set are adjacent. Formally, for a graph with vertices \(1, 2, \dots, n\) and a set of edges, determine if it is possible to color each vertex using exactly two colors, say 0 and 1, such that for every edge \((u, v)\), the colors of \(u\) and \(v\) are different.

Input Constraints: The first line contains two integers \(n\) and \(m\) which denote the number of vertices and the number of edges respectively. The following \(m\) lines each contain two integers \(u\) and \(v\) representing an edge between vertices \(u\) and \(v\).

Output: Output a single word: "Yes" if the graph is bipartite, and "No" otherwise.

inputFormat

The input is read from standard input (stdin). The first line contains two integers \(n\) (the number of vertices) and \(m\) (the number of edges). Each of the next \(m\) lines contains two integers \(u\) and \(v\), representing an undirected edge between vertices \(u\) and \(v\).

outputFormat

Print to standard output (stdout) "Yes" if the graph is bipartite, otherwise print "No".

## sample
4 4
1 2
2 3
3 4
4 2
No