Advertisement
999ms

Untitled

Jan 31st, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define all(x) (x).begin(),(x).end()
  3.  
  4. using namespace std;
  5. using ll = long long;
  6.  
  7. struct pt {
  8.     int x;
  9.     int y;
  10.     int ind;
  11.     pt(int cx = 0, int cy = 0, int cind = 0) {
  12.         this->x = cx;
  13.         this->y = cy;
  14.         this->ind = cind;  
  15.     }
  16.     bool operator < (const pt& o) {
  17.         return x < o.x || (x == o.x && y < o.y);
  18.     }
  19.     pt operator - (const pt& o) const {
  20.         return pt(x - o.x, y - o.y);
  21.     }
  22. };
  23.  
  24. int main() {
  25.     ios_base::sync_with_stdio(false);
  26.     cin.tie(nullptr);
  27.     cout.tie(nullptr);
  28.     int n;
  29.     cin >> n;
  30.     vector<pt> arr(n);
  31.     for (int i = 0; i < n; i++) {
  32.         cin >> arr[i].x >> arr[i].y;
  33.         arr[i].ind = i;
  34.     }
  35.     sort(all(arr));
  36.     sort(arr.begin() + 1, arr.end(), [&] (const pt& a, const pt& b) {
  37.         pt v1 = a - arr[0];
  38.         pt v2 = b - arr[0];
  39.         return v1.x * 1ll * v2.y - v1.y * 1ll * v2.x < 0;
  40.     });
  41.     cout << arr[0].ind + 1 <<  ' ' << arr[n / 2].ind + 1 << endl;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement