-
Notifications
You must be signed in to change notification settings - Fork 0
/
11723.java
39 lines (37 loc) · 1.06 KB
/
11723.java
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
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int m = Integer.parseInt(br.readLine());
boolean [] arr = new boolean [21], brr = new boolean[21], crr = new boolean[21];
for(int i=1;i<=20;i++)
brr[i]=true;
for(int i=0;i<m;i++) {
String[] cmd = br.readLine().split(" ");
String oper = cmd[0];
if(oper.equals("all")) {
arr=brr;
continue;
}
else if(oper.equals("empty")) {
arr=crr;
continue;
}
int val=Integer.parseInt(cmd[1]);
if(oper.equals("add"))
arr[val]=true;
else if(oper.equals("remove"))
arr[val]=false;
else if(oper.equals("check"))
bw.write(arr[val]?"1\n":"0\n");
else if(oper.equals("toggle"))
arr[val]=!arr[val];
}
bw.close();
}
}