forked from srikanthmalipatel/Spoj-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBUGLIFE-6859699-src.cpp
More file actions
66 lines (49 loc) · 1.26 KB
/
BUGLIFE-6859699-src.cpp
File metadata and controls
66 lines (49 loc) · 1.26 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
66
#include <iostream>
#include <vector>
using namespace std;
#define M 1 //masculino
#define F (-1) //femenino
#define U 0 //no marcado
#define PB push_back
vector<int> adj[21000];
short int g[21000]; //gender
bool DFS(int r){
bool res = true;
for(int i = 0; i < adj[r].size(); i++){
int v = adj[r][i];
if(g[v] == g[r]) return false;
if(g[v] == U){
g[v] = -g[r];
res = res and DFS(v);
}
}
return res;
}
int main(void){
int t = 0; cin >> t;
for(int tt = 1; tt <= t; tt++){
int n, m; scanf("%d%d",&n,&m);
for(int i = 0; i < n; i++){
g[i] = U;
adj[i].clear();
}
int x, y;
for( int i = 0; i < m; i++){
scanf("%d%d",&x,&y);
adj[x].PB(y); adj[y].PB(x);
}
printf("Scenario #%d:\n",tt);
bool result = true;
for(int i = 0; i < n; i++){
if(g[i] == U){
g[i] = M;
result = result and DFS(i);
}
}
if(result)
printf("No suspicious bugs found!\n");
else
printf("Suspicious bugs found!\n");
}
return 0;
}