-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno_pair.cpp
68 lines (52 loc) · 1.33 KB
/
no_pair.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
// To Check if a Given Point exists in an Interval or Not.
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fe(i,a,b) for(i=a;i<=b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
void print(vector<ll>& a, char sep = ' ')
{
for(auto i : a) { cout<<i<<sep; }
}
ll mod_opr(ll num)
{
return num % mod;
}
bool compare(ll x, ll y)
{
return x > y ? true : false;
}
int main()
{
// All the Operations are done in O(LogN) time.
set<pair<int, int> > S;
S.insert({401, 450});
S.insert({10, 20});
S.insert({2, 3});
S.insert({30, 400});
int point = 50;
auto it = S.upper_bound({point, INT_MAX});
if(it == S.begin())
{
cout<<"The Given Point is not Lying in any Interval..\n";
}
it--;
pair<int, int> current = *it;
if(current.first <= point && point <= current.second)
{
cout<<"Yes it's Present! : "<<current.first<<" "<<current.second<<endl;
}
else
{
cout<<"The Given Point is not Lying in any Interval..\n";
}
return 0;
}