QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#219955#4423. AMPPZ in the times of disease275307894aRE 0ms0kbC++141.5kb2023-10-19 20:09:152023-10-19 20:09:16

Judging History

你现在查看的是最新测评结果

  • [2023-10-19 20:09:16]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-19 20:09:15]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar() 
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;using LL=__uint128_t;
const int N=3e4+5,M=N*20+5,K=600+5,mod=998244353,Mod=mod-1;const db eps=1e-6;const int INF=1e9+7;mt19937 rnd(263082);
int n,k,fa[N],X[N],Y[N],col[N];
ll dist(int x,int y){return 1ll*(X[x]-X[y])*(X[x]-X[y])+1ll*(Y[x]-Y[y])*(Y[x]-Y[y]);}
pii MIN(pii x,pii y){return dist(x.fi,x.se)<dist(y.fi,y.se)?x:y;}
int GF(int x){return fa[x]^x?fa[x]=GF(fa[x]):x;}
void Solve(){
	int i,j,h;scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++) scanf("%d%d",&X[i],&Y[i]);
	iota(fa+1,fa+n+1,1);
	vector<int> scc;
	for(i=1;i<=k;i++) scc.eb(i);
	for(i=k+1;i<=n;i++){
		scc.eb(i);
		pair<int,int> ans={scc[0],scc[1]};
		for(j=0;j<scc.size();j++) for(h=j+1;h<scc.size();h++) ans=MIN(ans,make_pair(scc[j],scc[h]));
		fa[GF(ans.se)]=GF(ans.fi);for(j=0;j<scc.size();j++) if(scc[j]==ans.se) {scc.erase(scc.begin()+j);break;}
	}
	for(i=1;i<=n;i++) {
		for(j=0;j<scc.size();j++) if(GF(scc[j])==GF(i)) {printf("%d ",j+1);break;}
	}
	printf("\n");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

详细

Test #1:

score: 0
Runtime Error

input:

100
100000 20
270505 510725
245104 76414
131477 992924
781607 895592
562469 622976
564354 637966
980036 112090
522903 687218
113871 977855
6615 123673
13847 347618
657794 165707
420561 183995
11367 136391
507836 694877
985069 105115
774110 486921
14319 338715
774937 118145
981468 99089
803866 491315...

output:


result: