Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
33931 | 沈仲恩 | 【S】T1 | C++ | 通过 | 100 | 452 MS | 1828 KB | 2023 | 2024-10-30 15:39:39 |
#include <bits/stdc++.h> #define int long long using namespace std; map <int, int> mp1, //xi+yi=key mp2; //xi-yi=key struct poi { int x, y; } a[100005]; inline bool cmp(poi xx, poi yy) { return xx.x + xx.y < yy.x + yy.y; } inline bool cmp1(poi xx, poi yy) { return xx.x - xx.y < yy.x - yy.y; } int x[100005], y[100005]; signed main() { // freopen("pair.in", "r", stdin); // freopen("pair.out", "w", stdout); int _; scanf("%lld", &_); while (_--) { mp1.clear(); mp2.clear(); int n; scanf("%lld", &n); long double ans = 0; for (int i = 1; i <= n; i++) { scanf("%lld %lld", &a[i].x, &a[i].y); } sort(a + 1, a + n + 1, cmp); bool b = 0; for (int i = 2; i <= n; i++) { if (a[i].x + a[i].y == a[i - 1].x + a[i - 1].y) { printf("%.10Lf\n", sqrtl(2)); b = 1; break; } ans = max(ans, (abs(a[i - 1].x - a[i].x) + abs(a[i].y - a[i - 1].y)) / sqrtl((a[i].x - a[i - 1].x) * (a[i].x - a[i - 1].x) + (a[i].y - a[i - 1].y) * (a[i].y - a[i - 1].y))); } if (b) continue; sort(a + 1, a + n + 1, cmp1); for (int i = 2; i <= n; i++) { if (a[i].x - a[i].y == a[i - 1].x - a[i - 1].y) { printf("%.10Lf\n", sqrtl(2)); b = 1; break; } ans = max(ans, (abs(a[i - 1].x - a[i].x) + abs(a[i].y - a[i - 1].y)) / sqrtl((a[i].x - a[i - 1].x) * (a[i].x - a[i - 1].x) + (a[i].y - a[i - 1].y) * (a[i].y - a[i - 1].y))); } if (b) continue; printf("%.10Lf\n", ans); } return 0; } /* (x0, y0) 与 y=x+b 的距离 y0=-x0+b0 y=-x0/y0(x)+b0/y0 {y=x+b x+b=-x0/y0(x)+b0/y0 x+x0/y0(x)=b0/y0-b (1+x0/y0)x=b0/y0-b x=(b0/y0-b)/(1+x0/y0) y=x+b # */