-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11396 Claw Decomposition.cpp
59 lines (56 loc) · 1.11 KB
/
11396 Claw Decomposition.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
vector <int> node[10001];
#define pb push_back
int dis[10001];
bool biparte_chek(int src)
{
dis[src] = 0;
queue <int> q;
q.push(src);
int c= 0 , v , u;
bool f = true;
while(!q.empty() && f)
{
u = q.front();
q.pop();
for(int i = 0; i < node[u].size(); i++)
{
v = node[u][i];
if(dis[v] == -1)
{
dis[v] = dis[u] + 1;
q.push(v);
}
if(dis[u] == dis[v]){
f = false;
break;
}
}
}
return f;
}
int main()
{
int n;
while(scanf("%d", &n) == 1)
{
if(n == 0)
break;
memset(dis ,-1 , sizeof dis);
int a , b;
while(scanf("%d %d", &a ,&b))
{
if(a == 0 && b == 0) break;
node[a].pb(b);
node[b].pb(a);
}
bool k= biparte_chek(1);
if(k)
printf("YES\n");
else
printf("NO\n");
for(int i = 1; i <= n; i++)
node[i].clear();
}
}