| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 41405 | plj2026 | 【S】T1 | C++ | 通过 | 100 | 994 MS | 1828 KB | 1297 | 2026-04-22 19:07:41 |
#include <bits/stdc++.h> using namespace std; #define int long long struct nd { double x, y; }; nd dis[100005]; bool cmp(nd xx, nd yy) { if ((xx.x+xx.y) != (yy.x+yy.y)) return (xx.x+xx.y) < (yy.x+yy.y); return (xx.x-xx.y) < (yy.x-yy.y); } double mhd(int x1, int y1, int x2, int y2) { return 1.0*abs(x1-x2) + 1.0*abs(y1-y2); } double jld(int x1, int y1, int x2, int y2) { return 1.0*sqrt(1.0*(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); } signed main() { int t; cin >> t; while (t--) { int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> dis[i].x >> dis[i].y; } if (n<= 1000) { double maxn = 0; for (int i = 1; i < n; i++) { for (int j = i+1; j <= n; j++) { maxn = max(maxn,1.0*mhd(dis[i].x,dis[i].y,dis[j].x,dis[j].y)/ jld(dis[i].x,dis[i].y,dis[j].x,dis[j].y)); } } printf("%.12lf\n", maxn); } else { sort(dis+1, dis+n+1, cmp); double maxn = 0; for (int i = 1; i < n; i++) { maxn = max(maxn,1.0*mhd(dis[i].x,dis[i].y,dis[i+1].x,dis[i+1].y)/ jld(dis[i].x,dis[i].y,dis[i+1].x,dis[i+1].y)); } printf("%.12lf\n", maxn); } } return 0; } /*用例 2 2 0 0 0 1 3 1 1 2 3 5 8 1.000000000000 1.371988681140*/