forked from abhishekdoifode1/Hacktoberfest2021
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimakshat47_stlSets.cpp
73 lines (64 loc) · 1.68 KB
/
imakshat47_stlSets.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Sets are a part of the C++ STL. Sets are containers that store unique elements following a specific order.
1 x : Add an element to the set.
2 x : Delete an element from the set. (If the number is not present in the set, then do nothing).
3 x : If the number is present in the set, then print "Yes"(without quotes) else print "No"(without quotes).
Input Format
The first line of the input contains where is the number of queries. The next lines contain query each. Each query consists of two integers and where is the type of the query and is an integer.
Output Format
For queries of type print "Yes"(without quotes) if the number 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
*/
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
using namespace std;
int main()
{
set<int> s;
int t;
scanf("%d", &t);
while (t--)
{
int type, num;
scanf("%d %d", &type, &num);
if (type == 1)
{
s.insert(num);
}
else if (type == 2)
{
s.erase(num);
}
else if (type == 3)
{
auto it = s.find(num);
if (it == s.end())
{
printf("No\n");
}
else
{
printf("Yes\n");
}
}
}
return 0;
}