-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path11723.cpp
42 lines (40 loc) · 846 Bytes
/
11723.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
37
38
39
40
41
42
#include <iostream>
#include <cstring>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int M; cin >> M;
int bit=0;
int x;
string order;
while(M--){
cin >> order;
if (order=="add"){
cin >> x;
bit|=(1<<x);
}
else if(order=="remove"){
cin >> x;
bit&=~(1<<x);
}
else if(order=="check"){
cin >> x;
if(bit & (1 << x))
cout << 1 << "\n";
else
cout << 0 << "\n";
}
else if(order=="toggle"){
cin >> x;
bit ^=(1<<x);
}
else if(order=="all"){
bit = (1<<21)-1;
}
else if(order=="empty"){
bit = 0;
}
}
}