-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path11723.cpp
More file actions
69 lines (66 loc) · 902 Bytes
/
11723.cpp
File metadata and controls
69 lines (66 loc) · 902 Bytes
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
// 11723. 집합
// 2019.05.22
// 자료구조
#include<iostream>
#include<algorithm>
#include<set>
#include<string>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
set<int> s;
for (int i = 0; i < n; i++)
{
string order;
int x;
cin >> order;
switch (order[1])
{
case 'd': // add
cin >> x;
s.insert(x);
break;
case 'e': // remove
cin >> x;
s.erase(x);
break;
case 'h': //check
cin >> x;
if (s.find(x) != s.end())
{
cout << 1 << "\n";
}
else
{
cout << 0 << "\n";
}
break;
case 'o': // toggle
cin >> x;
if (s.find(x) != s.end())
{
s.erase(x);
}
else
{
s.insert(x);
}
break;
case 'l': // all
for (int i = 1; i <= 20; i++)
{
s.insert(i);
}
break;
case 'm': // empty
s.clear();
break;
}
}
return 0;
}