-
Notifications
You must be signed in to change notification settings - Fork 0
/
a bugs life.cpp
67 lines (61 loc) · 1.22 KB
/
a bugs life.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
60
61
62
63
64
65
66
67
#include<bits/stdc++.h>
#include<vector>
using namespace std;
vector< vector<int> > v;
int level[3000]={0};
bool visited[3000];
int g1[1000005][2];
void bfs(int s){
queue<int>q;
q.push(s);
level[s]=0;
visited[s]=true;
while(!q.empty()){
int p=q.front();
q.pop();
for(int i=0;i<v[p].size();i++){
if(visited[v[p][i]]==false){
level[v[p][i]]=level[p]+1;
q.push(v[p][i]);
visited[v[p][i]]=true;
}
}
}
}
void init(int n){
for(int i=0;i<n+5;i++){
visited[i]=false;
}
}
int main(){
int t;
cin>>t;
int k=0;
while(t--){
int nodes,edges,x,y;
cin>>nodes>>edges;
v.resize(nodes+5);
v.clear();
int i;
for(i=0;i<edges;i++){
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
g1[i][0]=x;
g1[i][1]=y;
}
init(nodes);
for(i=1;i<=nodes;i++){
if(visited[i]==false){bfs(i); }
}
int flag=0;
for(i=0;i<edges;i++){
if((level[g1[i][0]]-level[g1[i][1]])%2==0){
flag=1; break;
}
} k++;
if(flag==1){cout<<"Scenario #"<<k<<":\nSuspicious bugs found!\n";}
else{cout<<"Scenario #"<<k<<":\nNo Suspicious bugs found!\n";}
}
return 0;
}