-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1207.cpp
45 lines (40 loc) · 978 Bytes
/
1207.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
#include <iostream>
#include <algorithm>
struct point {
long long x;
long long y;
double angle;
int num;
bool operator<(point &other) { return angle < other.angle; }
};
using namespace std;
int main() {
int n;
cin >> n;
point points[n];
long long min_x = INT64_MAX;
int min_i = 0;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
points[i].x = x;
if (x < min_x) {
min_x = x;
min_i = i;
}
cin >> points[i].y;
points[i].num = i + 1;
}
for (point &p: points) {
if (p.num == min_i + 1) {
p.angle = INT32_MIN;
} else if (p.x == points[min_i].x) {
p.angle = (p.y > points[min_i].y) ? 90 : -90;
} else {
p.angle = (double) (p.y - points[min_i].y) / (p.x - points[min_i].x);
}
}
cout << points[min_i].num << " ";
sort(points, points + n);
cout << points[n / 2].num;
}