-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbugslife.cpp
More file actions
65 lines (58 loc) · 1.35 KB
/
bugslife.cpp
File metadata and controls
65 lines (58 loc) · 1.35 KB
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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
vi adj[2005];
int visited[2005];
int color[2005];
bool dfs(int s, int c){
visited[s] = 1;
color[s] = c;
for(int x: adj[s]){
if(!visited[x]){
if(dfs(x, c^1) == false){
return false;
}
}else{
if(color[x] == color[s]){
return false;
}
}
}
return true;
}
int main(){
ios_base::sync_with_stdio(false);cin.tie(nullptr);
int t;
cin >> t;
for(int i=0; i<t; i++){
int n, m;
cin >> n >> m;
for(int k=0; k<n; k++){
adj[k].clear();
visited[k] = 0;
}
for(int j=0; j<m; j++){
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
bool flag = true;
for(int t=0; t<n; t++){
if(!visited[t]){
if(!dfs(t, 1)){
flag = false;
}
}
}
cout << "Scenario #" << i+1 << ":\n";
if(!flag){
cout << "Suspicious bugs found!\n";
}else{
cout << "No suspicious bugs found!\n";
}
}
return 0;
}