-
Notifications
You must be signed in to change notification settings - Fork 558
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e91032
commit 02844bb
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |