Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #include <set>
- #include <cmath>
- #include <map>
- #include <utility>
- #define pi 3.14159265
- using namespace std;
- typedef long long ll;
- int inf = 1e9;
- void fastIO() {
- ios_base::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- }
- void solve() {
- int n, s;
- cin >> n >> s;
- int ma = s, mi = s;
- int prevt = 0;
- bool flag = true;
- for (int i = 0; i < n; i++) {
- int tt, l, r;
- cin >> tt >> l >> r;
- int t = tt - prevt;
- mi -= t;
- ma += t;
- if (l > ma || r < mi)
- flag = false;
- ma = min(ma, r);
- mi = max(mi, l);
- prevt = tt;
- }
- if (flag)
- cout << "YES\n";
- else
- cout << "NO\n";
- return;
- }
- double getans(int x1, int y1) {
- //int x1 = a.first.first, y1 = a.first.second;
- int x2 = 1000, y2 = 0;
- return acos(1.0 * (x1 * x2 + y1 * y2) / sqrt(x1 * x1 + y1 * y1) / sqrt(x2 * x2 + y2 * y2));
- }
- double getans1(int x1, int y1) {
- //int x1 = a.first.first, y1 = a.first.second;
- int x2 = -1000, y2 = 0;
- return acos(1.0 * (x1 * x2 + y1 * y2) / sqrt(x1 * x1 + y1 * y1) / sqrt(x2 * x2 + y2 * y2));
- }
- int main() {
- fastIO();
- int n;
- cin >> n;
- vector <pair<double, int>> a(n);
- for (int i = 0; i < n; i++) {
- int x, y;
- cin >> x >> y;
- if (y >= 0)
- a[i] = { getans(x, y), i };
- else a[i] = {pi + getans1(x, y), i };
- }
- sort(a.begin(), a.end());
- int i1, i2;
- double ans = 10;
- for (int i = 1; i < n; i++) {
- if (a[i].first - a[i - 1].first < ans) {
- ans = a[i].first - a[i-1].first;
- i1 = a[i-1].second;
- i2 = a[i].second;
- }
- }
- if (ans > 2 * pi - a[n - 1].first + a[0].first)
- cout << a[0].second+1<< " " << a[n-1].second+1;
- else
- cout << i1 + 1 << " " << i2 + 1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement