Point get_point_(Point p1, Point k1, Point p2, Point k2) { Point u = p1 - p2; double t = (k2 * u) / (k1 * k2); return {t * k1.x + p1.x, t * k1.y + p1.y}; }
Point get_point(const Line &l1, const Line &l2){returnget_point_(l1.st, l1.ed - l1.st, l2.st, l2.ed - l2.st);}
boolon_right(const Line &a, const Line &b, const Line &c) { Point t = get_point(b, c); returnsgn((a.ed - a.st) * (t - a.st)) <= 0; }
voidhalf_plane(Line l[], int n) { sort(l + 1, l + n + 1, lcmp); hh = 1; for (int i = 1; i <= n; ++ i) { if (i > 1 && !cmp(angle(l[i]), angle(l[i - 1]))) continue; while (hh < tt && on_right(l[i], l[q[tt - 1]], l[q[tt]])) tt --; while (hh < tt && on_right(l[i], l[q[hh]], l[q[hh + 1]])) hh ++; q[++ tt] = i; } while (hh < tt && on_right(l[q[hh]], l[q[tt - 1]], l[q[tt]])) tt --; while (hh < tt && on_right(l[q[tt]], l[q[hh]], l[q[hh + 1]])) hh ++; q[++ tt] = q[hh]; }
structPoint{ LD x, y; Point operator +(Point t)const{ return {x + t.x, y + t.y}; } Point operator -(Point t)const{ return {x - t.x, y - t.y}; } LD operator *(Point t)const{ return x * t.y - y * t.x; } }; structLine{ Point st, ed; vector<int> id; }l[N]; int q[N], hh, tt; int ki[N], vi[N];
auto angle = [](const Line &l){returnatan2(l.ed.y - l.st.y, l.ed.x - l.st.x);}; auto sgn = [](LD x){return (fabs(x) < eps) ? 0 : (x > 0 ? 1 : -1);}; auto cmp = [](LD x, LD y){returnsgn(x - y);}; auto lcmp = [](const Line &l1, const Line &l2){ LD A = angle(l1), B = angle(l2); if (cmp(A, B) == 0) returnsgn((l1.ed - l1.st) * (l2.ed - l1.st)) < 0; return A < B; };
Point get_point_(Point p1, Point k1, Point p2, Point k2) { Point del = p1 - p2; LD t = (k2 * del) / (k1 * k2); return {t * k1.x + p1.x, t * k1.y + p1.y}; }
Point get_point(const Line &l1, const Line &l2){returnget_point_(l1.st, l1.ed - l1.st, l2.st, l2.ed - l2.st);}
boolon_right(const Line &a, const Line &b, const Line &c) { Point t = get_point(b, c); returnsgn((t - a.st) * (a.ed - a.st)) > 0; }
voidhalf_plane(int n) { sort(l + 1, l + n + 1, lcmp); hh = 1, tt = 0; for (int i = 1; i <= n; ++ i) { if (i > 1 && !cmp(angle(l[i]), angle(l[i - 1]))) continue; while (hh < tt && on_right(l[i], l[q[tt - 1]], l[q[tt]])) tt --; while (hh < tt && on_right(l[i], l[q[hh]], l[q[hh + 1]])) hh ++; q[++ tt] = i; } while (hh < tt && on_right(l[q[tt]], l[q[hh]], l[q[hh + 1]])) hh ++; while (hh < tt && on_right(l[q[hh]], l[q[tt - 1]], l[q[tt]])) tt --; q[++ tt] = q[hh]; vector<int> ans; for (int i = hh; i < tt; ++ i) for (auto x : l[q[i]].id) ans.push_back(x); sort(ans.begin(), ans.end()); cout << ans.size() << endl; for (auto x : ans) cout << x << ' '; }
intmain() { map<PII, vector<int> > ids; int cnt = 0, n; cin >> n; l[++ cnt] = {{0, 0}, {10000, 0}, vector<int>(0)}; l[++ cnt] = {{0, 10000}, {0, 0}, vector<int>(0)}; for (int i = 1; i <= n; ++ i) cin >> ki[i]; for (int i = 1; i <= n; ++ i) cin >> vi[i]; for (int i = 1; i <= n; ++ i) ids[{ki[i], vi[i]}].push_back(i); for (constauto &c : ids) l[++ cnt] = {{0, c.first.first}, {1, c.first.first + c.first.second}, c.second}; half_plane(cnt); return0; }
constint N = 3e5 + 10; constdouble INF = 1e20, eps = 1e-12, Pi = acos(-1);
structPoint{ double x, y; Point operator +(Point t)const{ return {x + t.x, y + t.y}; } Point operator -(Point t)const{ return {x - t.x, y - t.y}; } Point operator *(double t)const{ return {x * t, y * t}; } Point operator /(double t)const{ return {x / t, y / t}; } doubleoperator *(Point t)const{ return x * t.y - y * t.x; } doubleoperator &(Point t)const{ return x * t.x + y * t.y; } }p[N], ans[4]; int stk[N], top, n; double mxa = INF;
intsgn(double x){ returnfabs(x) < eps ? 0 : (x > 0 ? 1 : -1); } intcmp(double x, double y){returnsgn(x - y);} doublelen(Point a){returnsqrt(a & a);} doublearea(Point a, Point b, Point c){return (b - a) * (c - a);} Point normal(Point t){return t / len(t);} Point rotate(Point a, double th){return {a.x * cos(th) + a.y * sin(th), a.y * cos(th) - a.x * sin(th)};} boolpcmp(Point a, Point b) { return a.x == b.x ? a.y < b.y : a.x < b.x; }
doubleproject(Point a, Point b, Point c) { return ((b - a) & (c - a)) / len(b - a); }
voidAndrew() { staticbool usd[N]; sort(p + 1, p + n + 1, pcmp); for (int i = 1; i <= n; ++ i) { while (top >= 2 && area(p[stk[top - 1]], p[stk[top]], p[i]) >= 0) usd[stk[top --]] = false; usd[stk[++ top] = i] = true; } usd[1] = false; for (int i = n; i; -- i) { if (usd[i]) continue; while (top >= 2 && area(p[stk[top - 1]], p[stk[top]], p[i]) >= 0) usd[stk[top --]] = false; usd[stk[++ top] = i] = true; } reverse(stk + 1, stk + top + 1); top --; }
voidfind_ju() { for (int i = 1, j = 3, k = 2, l = 3; i <= top; ++ i) { Point d = p[stk[i]], e = p[stk[i + 1]]; while (cmp(area(d, e, p[stk[j]]), area(d, e, p[stk[j + 1]])) < 0) j = j % top + 1; while (cmp(project(d, e, p[stk[k]]), project(d, e, p[stk[k + 1]])) < 0) k = k % top + 1; if (i == 1) l = j; while (cmp(project(d, e, p[stk[l]]), project(d, e, p[stk[l + 1]])) > 0) l = l % top + 1; Point x = p[stk[j]], y = p[stk[k]], z = p[stk[l]]; double h = area(d, e, x) / len(e - d), w = ((y - z) & (e - d)) / len(e - d); // cout << i << ' ' << h << ' ' << w << endl; if (h * w < mxa){ mxa = h * w; ans[0] = d + normal(e - d) * project(d, e, y); ans[3] = d + normal(e - d) * project(d, e, z); Point t = normal(rotate(e - d, -Pi / 2)); ans[1] = ans[0] + t * h; ans[2] = ans[3] + t * h; } } }
intmain() { cin >> n; for (int i = 1; i <= n; ++ i) cin >> p[i].x >> p[i].y; Andrew(); // cout << top << endl, exit(0); find_ju(); printf("%.5lf\n", mxa); int k = 0; for (int i = 1; i < 4; ++ i) if (cmp(ans[i].y, ans[k].y) < 0 || !cmp(ans[i].y, ans[k].y) && cmp(ans[i].x, ans[k].x) < 0) k = i; for (int i = 0; i < 4; ++ i, k ++) { if (k == 4) k = 0; double x = ans[k].x + eps, y = ans[k].y + eps; if (fabs(x) < eps) x = 0; if (fabs(y) < eps) y = 0; printf("%.5lf %.5lf\n", x, y); } return0; }