-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJ11723.java
More file actions
48 lines (43 loc) · 1.38 KB
/
Copy pathJ11723.java
File metadata and controls
48 lines (43 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package TIL;
import java.io.*;
import java.util.*;
public class J11723 {
public static void main(String[] args) throws IOException {
BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int T = Integer.parseInt(buffer.readLine());
int t = 0;
int n = 0;
while(T > t){
String[] input = buffer.readLine().split(" ");
String fun = input[0];
int num = 0;
if(!fun.equals("all") && !fun.equals("empty")) num = Integer.parseInt(input[1]);
switch(fun){
case "add" :
n |= 1<<(num-1);
break;
case "remove" :
num = ~(1<<(num-1));
n &= num;
break;
case "check" :
if((n & (1<<(num-1))) != 0) sb.append("1");
else sb.append("0");
sb.append("\n");
break;
case "all" :
n = (1<<20) -1;
break;
case "toggle" :
n ^= (1<<num-1);
break;
default :
n = 0;
break;
}
t++;
}
System.out.println(sb.toString());
}
}