-
Notifications
You must be signed in to change notification settings - Fork 0
/
6-ural-2067.cpp
57 lines (47 loc) · 1.12 KB
/
6-ural-2067.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
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
typedef long long LL;
int n;
struct P {
LL x, y, id;
bool operator<(const P& rhs) const {
return x == rhs.x ? y < rhs.y : x < rhs.x;
}
};
LL area2(P a, P b, P c) {
P ab{a.x - b.x, a.y - b.y, 0}, bc{b.x - c.x, b.y - c.y, 0};
return abs(ab.x * bc.y - ab.y * bc.x);
}
bool check_line(const vector<P>& ps) {
if (ps.size() < 3) return 1;
for (int i = 0; i < (int)ps.size() - 2; i++) {
if (area2(ps[i], ps[i + 1], ps[i + 2])) return 0;
}
return 1;
}
vector<P> ps;
int main() {
#ifdef D
freopen("f.in", "r", stdin);
#endif
while (~scanf("%d", &n)) {
for (int i = 1; i <= n; i++) {
int x, y;
scanf("%d%d", &x, &y);
ps.push_back({x, y, i});
}
auto line = ps;
sort(begin(line), end(line));
if (check_line(line)) {
printf("%d\n", 1);
printf("%lld ", line.front().id);
printf("%lld\n", line.back().id);
} else {
puts("0");
}
}
return 0;
}