Untitled
unknown
plain_text
16 days ago
2.1 kB
3
Indexable
#include <math.h> #include <iostream> #include <set> #include <vector> using namespace std; #define ll long long int tt, tc; const double PI = acos(-1); void solve() { int n; cin >> n; vector<pair<int, int>> in(n); for (auto& [f, l] : in) cin >> f >> l; set<double> angles; for (double i = 0; i < 360; i+= 0.5) { angles.insert(i); } auto cross = [&](tuple<double, double, double> a, tuple<double, double, double> b) { auto [x1, y1, z1] = a; auto [x2, y2, z2] = b; return make_tuple(y1 * z2 - z1 * y2, z1 * x2 - x1 * z2, x1 * y2 - y1 * x2); }; auto begin = INT32_MAX, end = INT32_MIN; for (int i = 0; i < n; i++) { auto [f, l] = in[i]; auto [f2, l2] = in[(i + 1) % n]; tuple<double, double, double> p1 = {cos(PI * l / 180.0), sin(PI * l / 180.0), sin(PI * f / 180.0)}; tuple<double, double, double> p2 = {cos(PI * l2 / 180.0), sin(PI * l2 / 180.0), sin(PI * f2 / 180.0)}; auto p3 = cross(p1, p2); double dot = get<2>(p3); if (abs(dot) < 1e-8) return void(cout << "yes\n"); // walk from l to l2 auto process = [&](double x){ auto ret = angles.find(x); if(ret != angles.end()) angles.erase(ret); }; double ld = l + 180, l2d = l2 + 180; if (l2d < ld) swap(ld, l2d); double dist1 = l2d - ld; double dist2 = 360 - dist1; double inc = dist2 < dist1 ? -0.5 : 0.5; if(ld == l2d){ process(ld); } while(ld != l2d) { process(ld); ld+= inc; if(ld < 0) l += 360; if(ld >= 360) l -= 360; } } if (angles.empty()) return void(cout << "yes\n"); cout << "no " << *angles.begin() - 180 << endl; // cout << (angles.begin() & 1 ? to_string(angles.begin() / 2) + ".5" : to_string(angles.begin() / 2) + ".0") << '\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); tt = 1, tc = 1; // cin >> tt; while (tt--) { solve(); tc++; } }
Editor is loading...
Leave a Comment