贪心也能过?

P1429 平面最近点对(加强版)

~~我拿这个写一篇题解应该没人会打我吧~~
by wangtairan114 @ 2023-10-19 20:02:19


智慧法挺多的吧
by tehllra @ 2023-10-19 20:41:40


@[tehllra](/user/325014) 我专门设置了一个变量,用时间换数据点,调高一点就骗过去了
by wangtairan114 @ 2023-10-23 19:56:40


康康代码
by arthurrr @ 2023-11-08 19:32:10


@[arthurrr](/user/1135375) ``` #include <cstring> #include <string> #include <stdio.h> #include <cmath> #include <algorithm> #include <iostream> #include <stack> #include <queue> #include <limits.h> #include <list> #include <set> #include <map> using namespace std; #define max(a,b) ((a)>(b)?(a):(b)) #define min(a,b) ((a)>(b)?(b):(a)) #define INF 0x3f3f3f3f #define ll long long #define sc scanf #define pr printf #define v1 first #define v2 second struct node{ double x,y; }a[200005]; int main() { int n; sc("%d",&n); for(int i=1; i <= n; i++) { sc("%lf%lf",&a[i].x,&a[i].y); } sort(a+1,a+n+1,[](node x,node y){if(x.x!=y.x)return x.x<y.x;return x.y<y.y;}); double minloc; double minn=1919810.00; for(int i=1; i <= n; i++) { minloc=1919810.00; int ok=30; for(int j=i-1; j >= 1; j--) { if(i!=j){ minloc=min(minloc,sqrt(abs(a[i].x-a[j].x)*abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)*abs(a[i].y-a[j].y))); if(sqrt(abs(a[i].x-a[j].x)*abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)*abs(a[i].y-a[j].y))>minloc&&!ok) break; else { if(sqrt(abs(a[i].x-a[j].x)*abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)*abs(a[i].y-a[j].y))>minloc) ok--; } } } for(int j=i+1; j <= n; j++) { if(i!=j){ minloc=min(minloc,sqrt(abs(a[i].x-a[j].x)*abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)*abs(a[i].y-a[j].y))); if(sqrt(abs(a[i].x-a[j].x)*abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)*abs(a[i].y-a[j].y))>minloc&&!ok) break; else { if(sqrt(abs(a[i].x-a[j].x)*abs(a[i].x-a[j].x)+abs(a[i].y-a[j].y)*abs(a[i].y-a[j].y))>minloc) ok--; } } } minn=min(minn,minloc); } pr("%.4lf",minn); } ```
by wangtairan114 @ 2023-11-11 08:57:39


@[wangtairan114](/user/1023189) P7883的点能骗过去不
by 20230332fuben @ 2024-01-04 21:37:32


@[20230332fuben](/user/1220105) 过不了 ~~试了,要是过了帖子也不会发在这里~~
by wangtairan114 @ 2024-01-13 15:00:31


|