fork download
  1. #include <cstdio>
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main(void)
  7. {
  8. ios_base::sync_with_stdio(false);
  9. int N, tt = 0;
  10. cin >> N;
  11.  
  12. for (int i = 0; i < N; i++) {
  13. char s[7] = { 0 };
  14. int x;
  15. cin >> s >> x;
  16. x--;
  17. if (!strcmp(s, "add")) tt = (tt | (1 << x));
  18. else if (!strcmp(s, "remove")) tt = (tt & ~(1 << x));
  19. else if (!strcmp(s, "check")) {
  20. if ((tt&(1 << x))>0) printf("1\n");
  21. else printf("0\n");
  22. }
  23. else if (!strcmp(s, "toggle")) tt = (tt ^ (1 << x));
  24. else if (!strcmp(s, "all"))
  25. tt = (1 << 21) - 1;
  26. else if (!strcmp(s, "empty")) tt = 0;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 4368KB
stdin
2
all
check 20
stdout
Standard output is empty