report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Bipartite graph - FlandreOJ: Flandre Online Judge

Bipartite graph

Time limit: 1000 ms
Memory limit: 256 MB
Given a undirected graph of $n$ vertices and $m$ edges. Determine whether or not this graph is a bipartite graph. A graph is bipartite if and only if you can color its vertices in 2 different colors such that no 2 adjacent vertices have the same color. ### Input - The first line contains 2 integers $n, m$. - The next $m$ lines, each line contains 2 integers $u, v$, there is an edge between $u$ and $v$. It is guaranteed that there is no loop. ### Output - Print `YES` if the given graph is bipartite, otherwise print `NO`. ### Constraints - $1 \le n, m \le 10^5$. - $1 \le u, v \le n$. ### Example Input: ``` 5 4 3 1 5 2 1 4 2 3 ``` Output: ``` YES ```
BFS / DFS
Connected component
Shortest path
Finding the path
Path on binary matrix
Garden
Operations on number
Bipartite graph
Tom and Jerry
Festival 1
Bamboo Forest of the Lost
Radar
Festival 2
Go
Escape from... dolls
Long leg
Lexicographically smallest path
Graph coloring
Topic
Graph
Rating 900
Solution (0) Solution