-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathADAFUROW.cpp
36 lines (36 loc) · 1 KB
/
ADAFUROW.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
// Ivan Carvalho
// Solution to https://www.spoj.com/problems/ADAFUROW/
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2 * 1e4 + 10;
typedef bitset<MAXN> bt;
bt linhas[MAXN];
int main() {
int q;
scanf("%d", &q);
while (q--) {
char op;
int x, y;
scanf(" %c %d %d", &op, &x, &y);
if (op == '+') {
linhas[x].flip(y);
} else if (op == '-') {
linhas[x].flip(y);
} else if (op == 'v') {
bt davez = linhas[x] | linhas[y];
printf("%d\n", (int)davez.count());
} else if (op == '^') {
bt davez = linhas[x] & linhas[y];
printf("%d\n", (int)davez.count());
} else if (op == '!') {
bt davez = linhas[x] ^ linhas[y];
printf("%d\n", (int)davez.count());
} else {
linhas[y].flip();
bt davez = linhas[x] & linhas[y];
printf("%d\n", (int)davez.count());
linhas[y].flip();
}
}
return 0;
}