#define _CRT_SECURE_NO_WARNINGS #include #include #include int main() { int set = 0; int N; scanf("%d",&N); getchar(); while(N--) { char str[20]; if (fgets(str, sizeof(str), stdin) == NULL) break; if (str[0] == '\n') { N++; continue; } str[strcspn(str, "\n")] = 0; char *opcode = strtok(str, " "); char *operend = strtok(NULL, " "); if(!strcmp(opcode, "add")) { set |= 1 << (atoi(operend)-1); } else if(!strcmp(opcode, "remove")) { set &= ~(1 << (atoi(operend)-1)); } else if(!strcmp(opcode, "check")) { printf("%d\n",set & (1 << (atoi(operend)-1)) ? 1 : 0); } else if(!strcmp(opcode, "toggle")) { set ^= 1 << (atoi(operend)-1); } else if(!strcmp(opcode, "all")) { set = (1<<20) - 1; } else if(!strcmp(opcode, "empty")) { set = 0; } } return 0; }