Skip to content

Commit

Permalink
Create 11723_2.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
encrypted-def authored Mar 17, 2024
1 parent 1e91032 commit 02844bb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Appendix C/11723_2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// http://boj.kr/5d6d3f1b55a04ea2a5bab1e7b9e28684
#include <bits/stdc++.h>
using namespace std;

int state;

int main(){
ios::sync_with_stdio(0);
cin.tie(0);

int m;
cin >> m;
while(m--){
string com;
int x;
cin >> com;
if(com == "add"){
cin >> x;
state |= (1 << (x-1));
}
else if(com == "remove"){
cin >> x;
state &= (~(1 << (x-1)));
}
else if(com == "check"){
cin >> x;
cout << ((state >> (x-1)) & 1) << '\n';
}
else if(com == "toggle"){
cin >> x;
state ^= (1 << (x-1));
}
else if(com == "all"){
state = 0xfffff;
}
else{ // empty
state = 0;
}
}
}

0 comments on commit 02844bb

Please sign in to comment.