1、称检测点查询
ACwing 3292
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> PII;
const int N = 210;
int n, a, b;
PII pos[N];
bool cmp(const PII &a, PII &b) {
if (a.first == b.first) return a.second < b.second;
return a.first < b.first;
}
int dist(int x, int y) {
return (x - a) * (x - a) + (y - b) * (y - b);
}
int main() {
cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
pos[i] = {
dist(x, y), i};
}
sort(pos, pos + n, cmp);
for (int i = 0; i < 3; i++) cout << pos[i].second + 1 << endl;
return 0;
}
2、风险人群筛查
ACwing 3293
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
const int N = 1010;
int n, k, t, xl, yl, xr, yr;
int s[N];
bool check(int x, int y) {
if (x >= xl && x <= xr && y >= yl && y <= yr) return true;
return false;
}
bool get() {
for (int i = k; i <= t; i++)
if (s[i] - s[i - k]