• CSP_2020091_称检测点查询


    题目描述

    方法暴力了点,但是主要就是学个语法。

    #include <iostream>
    #include <vector>
    #include <set> 
    #include <algorithm>
    #include <unordered_map>
    #include <string>
    #include <cstring>
    #include <math.h>
    using namespace std;
    
    const int INF = 0x3f3f3f3f;
    
    // id, dis
    bool cmp (pair<int, int> a, pair<int, int> b) {
    	if (a.second == b.second) {
    		return a.first < b.first;
    	} else {
    		return a.second < b.second;
    	}
    }
    
    int main() {
    	int n, x, y;
    	int x_p, y_p;
    	vector<pair<int, int>> points;
    	cin >> n >> x >> y;
    	for (int i = 0; i < n; i++) {
    		cin >> x_p >> y_p;
    		int d = pow(x-x_p, 2) + pow(y-y_p, 2);
    		auto pair = make_pair(i, d);
    		points.push_back(pair);
    	}
    	sort(points.begin(), points.end(), cmp);
    	for (int i =0; i<3; i++) {
    		cout << points[i].first+1 << endl;
    	}
    	return 0;
    }
    
  • 相关阅读:
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
    National Treasures HDU
    Matrix HDU
    过山车 HDU
    Jimmy’s Assignment HDU
    Card Game Cheater HDU
    Uncle Tom's Inherited Land* HDU
    50 years, 50 colors HDU
  • 原文地址:https://www.cnblogs.com/ticlab/p/15642332.html
Copyright © 2020-2023  润新知