-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathP11723.cc
39 lines (37 loc) · 879 Bytes
/
P11723.cc
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
#include <iostream>
#include <cstring>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int m;
cin >> m;
int set = 0;
char op[7];
int arg;
while (m--) {
cin >> op;
if (!strcmp(op, "add")) {
cin >> arg;
arg = 1 << arg;
set |= arg;
} else if (!strcmp(op, "remove")) {
cin >> arg;
arg = 1 << arg;
set &= ~arg;
} else if (!strcmp(op, "check")) {
cin >> arg;
arg = 1 << arg;
cout << !!(set & arg) << '\n';
} else if (!strcmp(op, "toggle")) {
cin >> arg;
arg = 1 << arg;
set ^= arg;
} else if (!strcmp(op, "all")) {
set = 0x1FFFFF;
} else {
set = 0;
}
}
}