-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathN11723.cpp
More file actions
89 lines (81 loc) · 1.51 KB
/
Copy pathN11723.cpp
File metadata and controls
89 lines (81 loc) · 1.51 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include <string>
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
class Cclac {
private:
int arr[20];
int size = sizeof(arr);
public:
Cclac() {
for (int i = 0; i < 20; i++) {
arr[i] = 0;
}
}
void add(int x) {
arr[x - 1] = x;
}
void remove(int x) {
arr[x - 1] = 0;
}
void check(int x) {
if (arr[x - 1] == 0) {
cout << "0" << endl;
}
else {
cout << "1" << endl;
}
}
void toggle(int x) {
if (arr[x - 1] == 0) {
add(x);
}
else {
remove(x);
}
}
void all() {
for (int i = 0; i < size; i++) {
arr[i] = i+1;
}
}
void empty() {
for (int i = 0; i < size; i++) {
arr[i] = 0;
}
}
};
int main() {
FASTIO;
int M,X;
string str;
cin >> M;
Cclac c;
while (M > 0) {
cin >> str;
if (str == "add") {
cin >> X;
c.add(X);
}
else if (str == "remove") {
cin >> X;
c.remove(X);
}
else if (str == "check") {
cin >> X;
c.check(X);
}
else if (str == "toggle") {
cin >> X;
c.toggle(X);
}
else if (str == "all") {
c.all();
}
else{
c.empty();
}
M--;
}
return 0;
}