-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11723.cpp
More file actions
40 lines (39 loc) · 1.03 KB
/
Copy path11723.cpp
File metadata and controls
40 lines (39 loc) · 1.03 KB
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
#include <bits/stdc++.h>
#define FastIO \
ios_base::sync_with_stdio(false); \
cin.tie(NULL); \
cout.tie(NULL);
using namespace std;
int main(void){
FastIO;
int m;//연산의 수
cin>>m;
int ret=0;
for(int i=0; i<m; i++){
string s;
cin>>s;
if(s=="add"||s=="remove"||s=="check"||s=="toggle"){
int p;
cin>>p;
p-=1;
if (s == "add") {//p번째 비트를 1로
ret = ret | (1<<p);
} else if (s == "remove") {//p번째 비트를 0으로
ret = ret & ~(1<<p);
} else if (s == "check") {//있으면1출력 없으면 0 출력
cout<<((ret&(1<<p)) ? 1 : 0)<<'\n';
} else if (s == "toggle") {
ret = ret ^ (1<<p);
}
}
else{
if(s=="all"){
ret = (1<<20)-1;
}
else{//empty
ret = 0;
}
}
}
return 0;
}