-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
36 lines (34 loc) · 872 Bytes
/
Copy pathmain.cpp
File metadata and controls
36 lines (34 loc) · 872 Bytes
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
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
char input[7];
int n, m, a, s;
n = 20;
s = 0;
scanf("%d", &m);
while(m--) {
scanf("%s", input);
if(!strcmp(input, "all")) {
s = (1 << n)-1;
} else if(!strcmp(input, "empty")) {
s = 0;
} else {
scanf("%d", &a);
a--;
if(!strcmp(input, "add")) {
s = (s | (1 << a));
} else if(!strcmp(input, "remove")) {
s = (s & ~(1 << a));
} else if(!strcmp(input, "check")) {
int temp = ( s & (1 << a));
if(temp) {
puts("1");
} else puts("0");
} else if(!strcmp(input, "toggle")) {
s = (s ^ (1 << a));
}
}
}
return 0;
}