-
Notifications
You must be signed in to change notification settings - Fork 0
/
buglife.cpp
61 lines (59 loc) · 1.25 KB
/
buglife.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
#include <iostream>
#include <cstring> //memset
#include <algorithm>
#include <bitset>
#include <string>
#include <vector>
#include <utility>
#include <cstdio>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>
using namespace std;
int main() {
freopen("input.txt", "r", stdin);
bool flagged;
int test_cases, bugs, interactions, bug1, bug2;
cin >> test_cases;
for (int i=1; i<= test_cases; i++) {
flagged = false;
cin >> bugs >> interactions;
int gender[bugs];
for (int i = 0; i < bugs; ++i) {
gender[i] = 0;
}
while (interactions--) {
cin >> bug1 >> bug2;
if (gender[bug1] != 0) {
if (gender[bug2] != 0) {
if ((gender[bug1] == 1 && gender[bug2] == 2) || (gender[bug2] == 1 && gender[bug1] == 2))
continue;
else
flagged = true;
}
else {
if (gender[bug1] == 1)
gender[bug2] = 2;
else gender[bug2] = 1;
}
}
else {
if (gender[bug2] == 0) {
gender[bug1] = 1;
gender[bug2] = 2;
}
else {
if (gender[bug2] == 1)
gender[bug1] = 2;
else gender[bug1] = 1;
}
}
}
cout << "Scenario #" << i << ":" << endl;
if (flagged) cout << "Suspicious bugs found!" << endl;
else cout << "No suspicious bugs found!" << endl;
}
return 0;
}