-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11723.cpp
More file actions
45 lines (40 loc) · 1010 Bytes
/
11723.cpp
File metadata and controls
45 lines (40 loc) · 1010 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
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int bit=0;
int main(){
ios_base :: sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int m; cin>>m;
for(int i=1; i<=m; i++){
string str; cin>>str;
if(str.compare("add")==0){
int x; cin>>x;
bit = bit | (1<<x) ;
}
else if(str.compare("remove")==0){
int x; cin>>x;
bit = bit & ~(1<<x);
}
else if(str.compare("check")==0){
int x; cin>>x;
if((bit & (1<<x))) cout<<"1\n";
else cout<<"0\n";
}
else if(str.compare("toggle")==0){
int x; cin>>x;
if((bit & (1<<x))) bit = bit ^ (1<<x);
else bit = bit | (1<<x);
// bit = bit ^ (1<<x);
}
else if(str.compare("all")==0){
bit = (1<<21)-1;
}
else if(str.compare("empty")==0){
bit=0;
}
}
return 0;
}