Advertisement
OIQ

xxxxx

OIQ
Feb 22nd, 2020
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <vector>
  4. #include <set>
  5. #include <cmath>
  6. #include <map>
  7. #include <utility>
  8. #define pi 3.14159265
  9. using namespace std;
  10. typedef long long ll;
  11. int inf = 1e9;
  12.  
  13. void fastIO() {
  14.     ios_base::sync_with_stdio(false);
  15.     cin.tie(0);
  16.     cout.tie(0);
  17. }
  18. void solve() {
  19.     int n, s;
  20.     cin >> n >> s;
  21.     int ma = s, mi = s;
  22.     int prevt = 0;
  23.     bool flag = true;
  24.     for (int i = 0; i < n; i++) {
  25.         int tt, l, r;
  26.         cin >> tt >> l >> r;
  27.         int t = tt - prevt;
  28.         mi -= t;
  29.         ma += t;
  30.         if (l > ma || r < mi)
  31.             flag = false;
  32.         ma = min(ma, r);
  33.         mi = max(mi, l);
  34.         prevt = tt;
  35.     }
  36.     if (flag)
  37.         cout << "YES\n";
  38.     else
  39.         cout << "NO\n";
  40.     return;
  41. }
  42.  
  43. double getans(int x1, int y1) {
  44.     //int x1 = a.first.first, y1 = a.first.second;
  45.     int x2 = 1000, y2 = 0;
  46.     return acos(1.0 * (x1 * x2 + y1 * y2) / sqrt(x1 * x1 + y1 * y1) / sqrt(x2 * x2 + y2 * y2));
  47. }
  48.  
  49. double getans1(int x1, int y1) {
  50.     //int x1 = a.first.first, y1 = a.first.second;
  51.     int x2 = -1000, y2 = 0;
  52.     return acos(1.0 * (x1 * x2 + y1 * y2) / sqrt(x1 * x1 + y1 * y1) / sqrt(x2 * x2 + y2 * y2));
  53. }
  54. int main() {
  55.     fastIO();
  56.    
  57.     int n;
  58.     cin >> n;
  59.  
  60.     vector <pair<double, int>> a(n);
  61.     for (int i = 0; i < n; i++) {
  62.         int x, y;
  63.         cin >> x >> y;
  64.         if (y >= 0)
  65.              a[i] = { getans(x, y), i };
  66.         else a[i] = {pi + getans1(x, y), i };
  67.     }
  68.     sort(a.begin(), a.end());
  69.     int i1, i2;
  70.     double ans = 10;
  71.  
  72.     for (int i = 1; i < n; i++) {
  73.         if (a[i].first - a[i - 1].first < ans) {
  74.             ans = a[i].first - a[i-1].first;
  75.             i1 = a[i-1].second;
  76.             i2 = a[i].second;
  77.  
  78.         }
  79.     }
  80.     if (ans > 2 * pi - a[n - 1].first + a[0].first)
  81.         cout << a[0].second+1<< " " << a[n-1].second+1;
  82.     else
  83.         cout << i1 + 1 << " " << i2 + 1;
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement