-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbluetooth.cpp
More file actions
52 lines (52 loc) · 1.2 KB
/
bluetooth.cpp
File metadata and controls
52 lines (52 loc) · 1.2 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
// GitHub: EntityPlantt/Kattis
#include <iostream>
#include <string.h>
#include <algorithm>
using namespace std;
int main() {
bool upperLeft[8], upperRight[8], lowerLeft[8], lowerRight[8], disabledLeft = false, disabledRight = false;
memset(upperLeft, true, sizeof(upperLeft));
memset(upperRight, true, sizeof(upperRight));
memset(lowerLeft, true, sizeof(lowerLeft));
memset(lowerRight, true, sizeof(lowerRight));
int n;
cin >> n;
for (int i = 0; i < n; i++) {
char a, b, status;
cin >> a >> b >> status;
if (status == 'b') {
if (isdigit(a)) {
disabledRight = true;
}
else {
disabledLeft = true;
}
if (disabledLeft && disabledRight) {
cout << 2;
return 0;
}
}
else if (a == '-') {
lowerLeft[b - '1'] = false;
}
else if (a == '+') {
upperLeft[b - '1'] = false;
}
else if (b == '-') {
lowerRight[a - '1'] = false;
}
else if (b == '+') {
upperRight[a - '1'] = false;
}
}
if (!disabledLeft && count(lowerLeft, lowerLeft + 8, true) && count(upperLeft, upperLeft + 8, true)) {
cout << 0;
}
else if (!disabledRight && count(lowerRight, lowerRight + 8, true) && count(upperRight, upperRight + 8, true)) {
cout << 1;
}
else {
cout << 2;
}
return 0;
}