称检测点查询
作者:互联网
参考代码:
#include <iostream>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 205;
struct cmp
{
bool operator()(pair<int,int> a, pair<int,int> b){
if(a.first==b.first){
return a.second<b.second;
}
return a.first < b.first;
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n,x,y;
cin>>n>>x>>y;
pair<int,int> rem[maxn];
int rx,ry,rs;
for(int i = 0; i<n;i++)
{
cin>>rx>>ry;
rs = (int)(abs(rx-x)*abs(rx-x)+abs(ry-y)*abs(ry-y));
pair<int,int> pr(make_pair(rs,i+1));
rem[i] = pr;
}
sort(rem,rem+n,cmp());
for(int i = 0; i<3;i++){
cout<<rem[i].second<<endl;
}
return 0;
}
标签:int,rx,ry,查询,abs,rem,pair,检测点 来源: https://www.cnblogs.com/Acapplella/p/14142624.html