import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
boolean[] Array = new boolean[21];
StringBuilder sb = new StringBuilder();
for (int i = 0; i < N; i++)
{
StringTokenizer st = new StringTokenizer(br.readLine());
String fct = st.nextToken();
if (fct.equals("all"))
{
for (int j = 1; j < 21; j++)
{
Array[j] = true;
}
continue;
}
if (fct.equals("empty"))
{
for (int k = 1; k < 21; k++)
{
Array[k] = false;
}
continue;
}
int num = Integer.parseInt(st.nextToken());
if (fct.equals("add"))
{
Array[num] = true;
}
if (fct.equals("check"))
{
if (Array[num])
{
sb.append(1).append("\n");
}
else {
sb.append(0).append("\n");
}
}
if (fct.equals("remove"))
{
Array[num] = false;
}
if (fct.equals("toggle"))
{
if (Array[num])
{
Array[num] = false;
continue;
}
else {
Array[num] = true;
continue;
}
}
}
System.out.println(sb);
}
}
흥미로운 문제였다. 원래는 배열을 숫자 배열로 만들었는데 boolean배열로 만드니 훨씬 깔끔해졌다.