#K41982. Bipartite Graph Coloring

    ID: 26986 Type: Default 1000ms 256MiB

Bipartite Graph Coloring

Bipartite Graph Coloring

Given an undirected graph \(G=(V,E)\) with \(N\) nodes and \(M\) edges, determine if it is possible to color each node using two colors such that no two adjacent nodes share the same color. This is equivalent to checking whether the graph is bipartite.

If the graph is bipartite, print YES; otherwise, print NO.

inputFormat

The first line contains two integers \(N\) and \(M\), representing the number of nodes and the number of edges, respectively. Each of the next \(M\) lines contains two integers \(u\) and \(v\), representing an undirected edge between the nodes \(u\) and \(v\).

outputFormat

Output a single line containing YES if the graph is bipartite or NO otherwise.

## sample
3 2
1 2
2 3
YES