← 返回 microsoft 的题目列表Possible Bipartition Variation
类型:online_judge
Problem: Possible Bipartition
Given n people labeled from 1 to n and an array dislikes, where dislikes[i] = [a, b] means person a and person b do not want to be in the same group.
Determine whether it is possible to split everyone into two groups such that every pair of people who dislike each other are in different groups.
Input Format
The first line contains two integers n m, the number of people and the number of dislike relationships.
The next m lines each contain two integers a b, meaning a and b cannot be in the same group.
Output Format
Print true if such a bipartition is possible; otherwise print false.
Constraints
1 <= n <= 2000
0 <= m <= 10^4
1 <= a, b <= n
a != b
Example
Input:
4 3
1 2
1 3
2 4
Output:
true
Example
Input
4 3
1 2
1 3
2 4
Output
true