📄 1019.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1019 on 2005-12-23 at 00:16:59 */
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX = 128;
class Tree {
public:
int x, y;
void init();
bool in(int, int, int, int) const;
};
void Tree::init() {
scanf("%d %d", &x, &y);
}
bool Tree::in(int l, int r, int u, int d) const {
return (l <= x && x <= r && u <= y && y <= d);
}
int main()
{
Tree tree[MAX];
int n, l;
int i, j, t, T;
scanf("%d", &T);
for(t = 0; t < T; t++) {
scanf("%d %d", &n, &l);
for(i = 0; i < n; i++) {
tree[i].init();
}
int most = 0;
for(i = 0; i < n; i++) {
int a = 0, b = 0, c = 0, d = 0;
for(j = 0; j < n; j++) {
if(tree[j].in(tree[i].x, tree[i].x+l, tree[i].y-l, tree[i].y)) a++;
if(tree[j].in(tree[i].x-l, tree[i].x, tree[i].y-l, tree[i].y)) b++;
if(tree[j].in(tree[i].x, tree[i].x+l, tree[i].y, tree[i].y+l)) c++;
if(tree[j].in(tree[i].x-l, tree[i].x, tree[i].y, tree[i].y+l)) d++;
}
most = max(most, a); most = max(most, b);
most = max(most, c); most = max(most, d);
}
printf("%d\n", most);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -