📄 3351802_ac_5750ms_4204k.cc
字号:
#include <stdio.h>
#include <algorithm>
using namespace std;
struct point
{
int x, y;
bool operator < (const point &t) const
{
return (x < t.x) || (x == t.x && y < t.y);
}
bool operator == (const point &t) const
{
return x == t.x && y == t.y;
}
};
int n;
point p[500001];
int have(int x,int y)
{
int min, max, mid;
point t;
t.x = x;t.y = y;
min = 0;max = n-1;
while (min <= max)
{
mid = (min + max) >> 1;
if (p[mid] == t)
return 1;
else
{
if (p[mid] < t)
min = mid+1;
else
max = mid-1;
}
}
return 0;
}
int main()
{
int i, w, h;
scanf("%d",&n);
scanf("%d%d",&w,&h);
for (i = 0; i < n; i++)
{
scanf("%d%d",&p[i].x,&p[i].y);
}
sort(p,p+n);
int ans = 0;
for (i = 0; i < n; i++)
{
if (have(p[i].x+w,p[i].y)&&have(p[i].x,p[i].y+h)&&have(p[i].x+w,p[i].y+h))
ans++;
}
printf("%d\n",ans);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -