QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343091 | #4423. AMPPZ in the times of disease | tz3528 | WA | 6825ms | 5540kb | C++20 | 1.0kb | 2024-03-01 22:06:18 | 2024-03-01 22:06:19 |
Judging History
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;
for(int j=2;j<=n;j++){
if(flag[j]) continue;
for(auto it:h){
if(dist(p[it],p[j])<sum){
sum=dist(p[it],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
Wrong Answer
time: 6825ms
memory: 5540kb
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:
1 1 14 1 1 1 2 1 17 1 1 2 1 1 1 2 2 1 2 2 2 2 14 1 1 1 1 1 14 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 14 1 1 2 1 14 1 2 14 14 2 1 1 1 14 14 2 2 1 1 1 2 1 1 2 1 2 1 1 1 2 2 2 2 1 1 2 14 2 18 1 1 1 1 2 1 1 1 14 14 1 2 1 2 14 2 1 1 1 1 14 1 1 2 2 1 1 14 1 1 1 1 14 1 1 1 1 1 2 1 1 1 2 2 1 1 1 1 1 1 14 1 2 14 1 ...
result:
wrong answer wrong solution (test case 1)