-
Notifications
You must be signed in to change notification settings - Fork 0
/
A_set.cpp
56 lines (49 loc) · 1.06 KB
/
A_set.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
#include <bits/stdc++.h>
using namespace std;
int main()
{
set<int>s;
int q;
cin>>q;
while(q--)
{
string str;
cin>>str;
if (str == "lower_bound")
{
int x;
cin >> x;
auto i =s.lower_bound(x);
if(i == s.end())
cout<<"-1"<<endl;
else
cout << *i << endl;
}
else if (str == "upper_bound")
{
int x;
cin >> x;
auto i = s.upper_bound(x);
if(i == s.end())
cout<<"-1"<<endl;
else
cout << *i << endl;
}
else if(str == "insert")
{
int x;
cin >> x;
s.insert(x);
}
else if(str == "find")
{
int x;
cin >> x;
auto pos = s.find(x);
if(pos!=s.end())
cout << "found" <<endl;
else
cout << "not found "<<endl;
}
}
}