File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments