8000 Create 11723.cpp · hackerman91/basic-algo-lecture@94e3653 · GitHub
[go: up one dir, main page]

Skip to content

Commit 94e3653

Browse files
Create 11723.cpp
1 parent cbcd96f commit 94e3653

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Appendix C/solutions/11723.cpp

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

0 commit comments

Comments
 (0)
0