Submission #119704

#TimeUsernameProblemLanguageResultExecution timeMemory
119704tutis2circles (balkan11_2circles)C++17
40 / 100
92 ms65536 KiB
/*input 6 0 0 8 0 8 6 4 8 2 8 0 4 */ #pragma GCC optimize ("O3") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; struct point { ld x, y; point() {} point(ld x, ld y): x(x), y(y) {} ld r() { return sqrtl(x * x + y * y); } }; point operator+(const point &a, const point &b) { return point(a.x + b.x, a.y + b.y); } point operator-(const point &a, const point &b) { return point(a.x - b.x, a.y - b.y); } point operator*(const point &a, const point &b) { return point(a.x * b.x - a.y * b.y, a.x * b.y + a.y * b.x); } point operator*(point a, ld k) { return point(a.x * k, a.y * k); } ld dot(const point &a, const point &b) { return a.x * b.x + a.y * b.y; } ld cross(const point &a, const point &b) { return a.x * b.y - a.y * b.x; } point x(const point &a, point b, const point &c, point d) { b = b - a; d = d - c; ld y = cross(a - c, b) / cross(d, b); return c + d * y; } ld y(const point &a, point b, const point &c, point d) { b = b - a; d = d - c; return cross(a - c, b) / cross(d, b); } struct line { point a, b; }; point x(const line &a, const line &b) { return x(a.a, a.b, b.a, b.b); } ld y(const line &a, const line &b) { return y(a.a, a.b, b.a, b.b); } int n; point A[50505]; bool nereik(const line &a, const line &b, const line &c) { return y(a, b) >= y(c, b); } deque<line> taisom(deque<line>a) { if (a.size() <= 2) return {}; for (int i = 0; i < (int)a.size(); i++) { int j = (i + 1) % a.size(); int k = (i + 2) % a.size(); if (abs(cross(a[i].b - a[i].a, a[k].b - a[k].a)) > 1e-7) { if (nereik(a[i], a[j], a[k])) { //cout << fixed << setprecision(3) << "- Line((" << a[j].a.x << "," << a[j].a.y << "),(" << // a[j].b.x << "," << a[j].b.y << "))" << endl; a.erase(a.begin() + j); return taisom(a); } } else { if (cross(a[k].a - a[i].a, a[i].b - a[i].a) > 0) return {}; } } return a; } deque<point>x(deque<line>a) { deque<point>ret; for (int i = 0; i < (int)a.size(); i++) { ret.push_back(x(a[i], a[(i + 1) % a.size()])); } return ret; } ld maxi(const deque<point> &a) { ld ret = 0; for (int i = 0; i < (int)a.size(); i++) { for (int j = 0; j < i; j++) { ret = max(ret, (a[i] - a[j]).r()); } } return ret; } bool ok(ld r) { deque<line>tieses; for (int i = 0; i < n; i++) { point v = (A[i + 1] - A[i]) * point(0, 1); v = v * (r / v.r()); tieses.push_back(line()); tieses.back().a = A[i] + v; tieses.back().b = A[i + 1] + v; } //for (auto i : tieses) //{ // cout << fixed << setprecision(3) << "Line((" << i.a.x << "," << i.a.y << "),(" << // i.b.x << "," << i.b.y << "))" << endl; //} tieses = taisom(tieses); //cout << endl << endl; //for (auto i : tieses) //{ // cout << fixed << setprecision(3) << "Line((" << i.a.x << "," << i.a.y << "),(" << // i.b.x << "," << i.b.y << "))" << endl; //} ld rr = maxi(x(tieses)); //cout << rr << endl; return rr >= 2 * r; } int main() { ios_base::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) cin >> A[i].x >> A[i].y; A[n] = A[0]; ld lo = 0; ld hi = 1ll << 30; for (int t = 0; t < 50; t++) { ld r = (lo + hi) / 2; //cout << r << endl << endl; if (ok(r)) lo = r; else hi = r; } ld r = (lo + hi) / 2; cout << fixed << setprecision(15) << r << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...