QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#343090#4423. AMPPZ in the times of diseasetz3528RE 0ms0kbC++201.1kb2024-03-01 22:05:422024-03-01 22:05:42

Judging History

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

  • [2024-03-01 22:05:42]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-03-01 22:05:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct point {
	long long x,y;
};
long long dist(point a,point b){
	return (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y);
}
int main(){
	int z;
	cin>>z;
	for(int l=1;l<=z;l++){
		long long n,k;
		cin>>n>>k;
		vector<point> p(n+1);
		for(int i=1;i<=n;i++){
			cin>>p[i].x>>p[i].y;
		}
		vector<int> h,flag(n+1);
		h.push_back(1);
		flag[1]=1;
		for(int i=2;i<=k;i++){
			long long sum=4e18,q,s;
			if(i>2){
				for(int j=2;j<=n;j++){
					if(flag[j]) continue;
					for(int l=0;l<i-1;l++){
						if(dist(p[h[l]],p[j])<sum){
							sum=dist(p[h[l]],p[j]);
							q=j;
						}
					}
				}
			}
			sum=-4e18;
			for(int j=2;j<=n;j++){
				if(flag[j]) continue;
				if(dist(p[q],p[j])>sum){
					sum=dist(p[q],p[j]);
					s=j;
				}
			}
			flag[s]=1;
			h.push_back(s);
		}
		for(int i=1;i<=n;i++){
			long long sum=4e18,q;
			for(int j=0;j<k;j++){
				if(dist(p[i],p[h[j]])<sum){
					sum=dist(p[i],p[h[j]]);
					q=j+1;
					
				}
			}
			cout<<q<<' ';
		}
		cout<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

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: