Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
27885 | liuyile | 【BJ】T1 | C++ | 解答错误 | 13 | 138 MS | 344 KB | 1695 | 2024-03-31 13:30:53 |
#include <bits/stdc++.h> using namespace std; #define int long long #define double long double #define endl "\n" int n,m; struct node{ int x,y; friend node operator -(const node A,const node B){ return {A.x-B.x,A.y-B.y}; } friend int operator *(const node A,const node B){ return A.x*B.y-B.x*A.y; } friend int operator ^(const node A,const node B){ return A.x*B.x+A.y*B.y; } inline double len(){return x*x+y*y;} }T[1010]; inline int ABS(int x){return x<0?-x:x;} struct circ{ node O; int r; inline bool acr(node A,node B){ int L=(A-B).len(); A=A-O,B=B-O; int S=A*B; S=S*S; if(L*r*r>S){ if(((O-A)^(B-A))<0||((O-B)^(A-B))<0)return 0; return 1; } else return 0; } }C[1010]; int f[1010]; int p[1010]; inline int ff(int x){ return f[x]==x?x:f[x]=ff(f[x]); } inline void merge(int x,int y){ f[ff(x)]=ff(y); } signed main(){ ios::sync_with_stdio(0); // freopen("beacons.in","r",stdin); // freopen("beacons.out","w",stdout); srand(time(0)); cin>>n>>m; for(int i=1;i<=n;i++)cin>>T[i].x>>T[i].y,f[i]=i,p[i]=i; for(int i=1;i<=m;i++)cin>>C[i].O.x>>C[i].O.y>>C[i].r; random_shuffle(T+1,T+n+1); int res=0; for(int i=1;i<=n;i++){ random_shuffle(C+1,C+m+1); random_shuffle(p+1,p+n+1); for(int j=1;j<=n;j++) if(ff(i)!=ff(p[j])){ bool s=1; for(int k=1;k<=m&&s;k++) if(C[k].acr(T[i],T[p[j]]))s=0; if(s)res++,merge(i,p[j]); } } cout<<n-1-res<<endl; cout.flush(); return 0; }