Skip to content

Commit 02844bb

Browse files
Create 11723_2.cpp
1 parent 1e91032 commit 02844bb

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

Appendix C/11723_2.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// http://boj.kr/5d6d3f1b55a04ea2a5bab1e7b9e28684
2+
#include <bits/stdc++.h>
3+
using namespace std;
4+
5+
int state;
6+
7+
int main(){
8+
ios::sync_with_stdio(0);
9+
cin.tie(0);
10+
11+
int m;
12+
cin >> m;
13+
while(m--){
14+
string com;
15+
int x;
16+
cin >> com;
17+
if(com == "add"){
18+
cin >> x;
19+
state |= (1 << (x-1));
20+
}
21+
else if(com == "remove"){
22+
cin >> x;
23+
state &= (~(1 << (x-1)));
24+
}
25+
else if(com == "check"){
26+
cin >> x;
27+
cout << ((state >> (x-1)) & 1) << '\n';
28+
}
29+
else if(com == "toggle"){
30+
cin >> x;
31+
state ^= (1 << (x-1));
32+
}
33+
else if(com == "all"){
34+
state = 0xfffff;
35+
}
36+
else{ // empty
37+
state = 0;
38+
}
39+
}
40+
}

0 commit comments

Comments
 (0)