1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> #include <algorithm> #include <map> #include <cstdio> #include <cstdlib> using namespace std; int n,posx,posy; struct s{ int dist2; int id; bool operator < (const s& s2) const{ if(dist2!=s2.dist2)return dist2 < s2.dist2; return id<s2.id; } }arrS[1000]; inline int calDist(int posx,int posy, int x, int y){ return (posx-x)*(posx-x)+(posy-y)*(posy-y); } int main() { ios::sync_with_stdio(false); cin>>n>>posx>>posy; for(int i=1;i<=n;i++){ int x,y; cin>>x>>y; arrS[i].dist2=calDist(posx,posy,x,y); arrS[i].id=i; } sort(arrS+1,arrS+1+n); for(int i=1;i<=3;i++){ cout<<arrS[i].id<<"\n"; } } |
CSP 202009-1 称检测点查询
发表评论