标签:ace names const ++i scan tps sed for ring
按顺序对于每个座位找一个最近的同时编号最小的牛就行了
#include<iostream>
#include<cstring>
#include<cstdio>
#define int long long
using namespace std;
const int MAXN=1010;
const int INF=1e18;
int n,m;
struct Data{
int x,y;
} c[MAXN],s[MAXN];
bool ok[MAXN],used[MAXN];
inline int dis(int i,int j){
return (c[i].x-s[j].x)*(c[i].x-s[j].x)+(c[i].y-s[j].y)*(c[i].y-s[j].y);
}
signed main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;++i)
scanf("%lld%lld",&c[i].x,&c[i].y);
for(int i=1;i<=m;++i)
scanf("%lld%lld",&s[i].x,&s[i].y);
for(int i=1;i<=m;++i){
int k=-1,minn=INF;
for(int j=1;j<=n;++j)
if(!used[j]&&dis(j,i)<minn)
k=j,minn=dis(j,i);
used[k]=1;
}
bool flag=1;
for(int i=1;i<=n;++i)
if(!used[i]){
printf("%lld\n",i);
flag=0;
}
if(flag) puts("0");
return 0;
}
【luoguP2994】[USACO10OCT]吃晚饭的时候Dinner Time
标签:ace names const ++i scan tps sed for ring
原文地址:https://www.cnblogs.com/yjkhhh/p/11744163.html