首页 > 其他 > 详细

2020.9 第1题

时间:2021-04-10 16:08:14      阅读:13      评论:0      收藏:0      [点我收藏+]
#include<bits/stdc++.h>
using namespace std;
struct pos{
    int x;
    int y;
};
bool cmp(pos& p1, pos& p2) {
    if (p1.y < p2.y) return true;
    else if (p1.y == p2.y) return p1.x < p2.x;
    else return false;
}
int main()
{
    // ios::sync_with_stdio(0);
    int n, X, Y;
    cin>>n>>X>>Y;
    struct pos ps[n + 1]; //记录数值
    struct pos dis[n + 1]; //记录i和距离
    for (int i = 1; i <= n; i++) {
        cin>>ps[i].x>>ps[i].y;
    }
    for (int i = 1; i <= n; i++) {
        int x = ps[i].x;
        int y = ps[i].y;
        int place = (x - X)*(x - X) + (y - Y)*(y - Y);
        dis[i].x = i;
        dis[i].y = place;//juli
    }
    sort(dis + 1,dis + 1 + n, cmp);
    for (int i = 1; i <= 3; i++) {
        cout<<dis[i].x<<endl;
    }
    return 0;
}

 

2020.9 第1题

原文:https://www.cnblogs.com/Kkvass/p/14640713.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!