algorithm'''problem solve
[백준]11723 - 집합(설명X)
JunHwa Park
2020. 4. 10. 00:06
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 40 41 42 43 44 45 46 | #include <cstdio> #include <cstring> int main() { bool arr[21]{ true, }; int M; scanf("%d", &M); for (int i = 0; i < M; i++) { char str[7]; scanf("%s", str); if (!strcmp(str, "add")) { int num; scanf("%d", &num); arr[num] = true; } else if (!strcmp(str, "remove")) { int num; scanf("%d", &num); arr[num] = false; } else if (!strcmp(str, "check")) { int num; scanf("%d", &num); if (arr[0]) printf("%d\n", arr[num]); else printf("%d\n", !arr[num]); } else if (!strcmp(str, "toggle")) { int num; scanf("%d", &num); arr[num] = !arr[num]; } else if (!strcmp(str, "all")) { arr[0] = true; for (int i = 1; i <= 20; i++) arr[i] = true; } else if (!strcmp(str, "empty")) { arr[0] = true; for (int i = 1; i <= 20; i++) arr[i] = false; } } return 0; } | cs |