-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp-sets.cpp
More file actions
30 lines (24 loc) · 787 Bytes
/
Copy pathcpp-sets.cpp
File metadata and controls
30 lines (24 loc) · 787 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
#include <iostream>
#include <set>
int main()
{
auto s = std::set<int>{};
auto numer_of_queries = unsigned{};
std::cin >> numer_of_queries;
enum class QueryType {
Add = 1,
Delete,
Find
};
auto query_type = unsigned{};
auto query_argument = decltype(s)::value_type{};
for (auto i = unsigned{0}; i < numer_of_queries; i++) {
std::cin >> query_type >> query_argument;
switch (static_cast<QueryType>(query_type)) {
case QueryType::Add : s.insert(query_argument); break;
case QueryType::Delete : s.erase(query_argument); break;
case QueryType::Find : std::cout << (s.find(query_argument) != s.end() ? "Yes\n" : "No\n"); break;
}
}
return 0;
}