You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
#define x first
#define y second
PII a[110];
int n, L;
vector<int> X, Y;
int ans;
int main() {
cin >> n >> L;
for (int i = 1; i <= n; ++i) {
cin >> a[i].x >> a[i].y;
/*
1按照输入的坐标先把所有可能的最终边长为L的正方形左上角坐标保存起来
2枚举正方形的左上角再去统计一下有多少点在这个正方形中。取最大值。
*/
X.push_back(a[i].x);
X.push_back(a[i].x - L); // 边长固定是L
Y.push_back(a[i].y);
Y.push_back(a[i].y - L);
}
for (int i = 0; i < X.size(); i++) // 所有可能的左上角横坐标
for (int j = 0; j < Y.size(); j++) { // 所有可能的左上角纵坐标
int cnt = 0;
int x = X[i], y = Y[j];
// 枚举出的就是所有可能的正方形
for (int k = 1; k <= n; k++) // 枚举每个金矿的坐标
// 如果此金矿的坐标,在当前枚举的正方形内部或边界上,就是覆盖到了这个金矿
if (a[k].x >= x && a[k].x <= x + L && a[k].y >= y && a[k].y <= y + L)
cnt++;
ans = max(ans, cnt);
}
cout << ans << endl;
return 0;
}