-
Notifications
You must be signed in to change notification settings - Fork 0
/
g.cpp
79 lines (57 loc) · 1.51 KB
/
g.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
74
75
76
77
78
79
#include <bits/stdc++.h>
#define int long long int
using namespace std;
using pii = pair<int,int>;
struct pt{
int x,y,id;
pt operator -(const pt &a){ return {x - a.x,y - a.y}; }
int operator /(const pt &a){ return {x * a.y - y * a.x}; }
bool operator <(const pt &a){
if(x != a.x) return x < a.x;
return y < a.y;
}
bool operator ==(const pt &a){
if(x != a.x) return x != a.x;
else if(y != a.y) return y != a.y;
else return id != a.id;
}
};
int n;
set<int> r;
vector<pt> v,u,l,c;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> n;
for(int i = 1;i <= n;i++){
int x,y;
cin >> x >> y;
v.push_back({x,y,i});
}
sort(v.begin(),v.end());
int it1 = 0,it2 = 0;
for(int i = 0;i < n;i++){
while(it1 > 1 && (v[i] - u[it1 - 2]) / (u[it1 - 1] - u[it1 - 2]) < 0){
u.pop_back();
it1--;
}
u.push_back(v[i]);
it1++;
while(it2 > 1 && (v[i] - l[it2 - 2]) / (l[it2 - 1] - l[it2 - 2]) > 0){
l.pop_back();
it2--;
}
l.push_back(v[i]);
it2++;
}
for(int i = 0;i < it1;i++)
c.push_back(u[i]);
for(int i = 0;i < it2;i++)
c.push_back(l[i]);
for(auto [x,y,i] : c)
r.insert(i);
for(auto i : r)
cout << i << " ";
return 0;
}