-
Notifications
You must be signed in to change notification settings - Fork 0
/
Sets-STL.cpp
57 lines (48 loc) · 1 KB
/
Sets-STL.cpp
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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
int q,y,x;
set<int> s;
cin>>q;
for(auto i=0;i<q;i++)
{
cin>>y>>x;
switch(y)
{
case 1: s.insert(x);
break;
case 2: s.erase(x);
break;
case 3: cout << (s.find(x) == s.end() ? "No" : "Yes") << endl;
}
}
return 0;
}
/*
1: Add an element x to the set.
2: Delete an element x from the set. (If the number is not present in the set, then do nothing).
3: If the number x is present in the set, then print "Yes"(without quotes) else print "No"(without quotes).
Output Format
For queries of type print "Yes"(without quotes) if the number x is present in the set and if the number is not present,then print "No"(without quotes).
Each query of type should be printed in a new line.
Sample Input
8
1 9
1 6
1 10
1 4
3 6
3 14
2 6
3 6
Sample Output
Yes
No
No
*/