-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11723.cpp
More file actions
62 lines (56 loc) · 975 Bytes
/
Copy path11723.cpp
File metadata and controls
62 lines (56 loc) · 975 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
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
62
#include<iostream>
#include<stdio.h>
using namespace std;
int key=0;
void add(int x){
key|=1<<x;
}
void remove(int x){
key&=~(1<<x);
}
void check(int x){
(key & (1 << (x))) ? printf("1\n") :printf("0\n");
}
void toggle(int x){
key = key ^ (1<<(x));
}
void all(){
key = (1<<21) - 1;
}
void empty(){
key = 0;
}
int main(){
int M,x;
cin>>M;
string cmd;
ios_base :: sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
while(M--){
cin>>cmd;
if(cmd=="add"){
cin>>x;
add(x);
}
else if(cmd=="remove"){
cin>>x;
remove(x);
}
else if(cmd=="check"){
cin>>x;
check(x);
}
else if(cmd=="toggle"){
cin>>x;
toggle(x);
}
else if(cmd=="all"){
all();
}
else if(cmd=="empty"){
empty();
}
}
return 0;
}