import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int M = Integer.parseInt(br.readLine());
int a = 0;
StringBuilder sb = new StringBuilder();
for(int i=0; i<M; i++) {
String[] s = br.readLine().split(" ");
switch(s[0]) {
case "all":
a = (1 << 21) - 1;
break;
case "empty":
a = 0;
break;
default:
int x = Integer.parseInt(s[1]);
switch(s[0]) {
case "add":
a |= (1 << x);
break;
case "remove":
a &= ~(1 << x);
break;
case "check":
sb.append((a & (1 << x)) != 0 ? 1 : 0).append('\n');
break;
case "toggle":
a ^= (1 << x);
break;
}
}
}
System.out.println(sb);
}
}
'Algorithm > 백준' 카테고리의 다른 글
백준 1654 (랜선 자르기) (0) | 2023.12.26 |
---|---|
백준 1874 (스택 수열) - Java (0) | 2023.12.02 |
백준 1620(나는야 포켓몬 마스터 이다솜) (0) | 2023.11.11 |
백준 18110 (solved.ac) (0) | 2023.10.08 |
자바 내림차순 정렬 하는 법 (0) | 2023.05.01 |