⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pku2859.cpp

📁 这是ACM 方面的资料 是PKU的 北京大学的出来的
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>
#define size 500010
typedef struct Point
{
	int x, y;
} Point;

Point p[size];
int N;
int Dx, Dy;

int cmp(const void *a, const void *b)
{
	Point *aa = (Point *)a;
	Point *bb = (Point *)b;
	if (aa->x == bb->x)
	{
		return aa->y - bb->y;
	}
	return aa->x - bb->x;
}

void Solve()
{
	int i, cnt;
	Point pn;
	scanf("%d %d", &Dx, &Dy);
	for (i = 0; i < N; i++)
	{
		scanf("%d %d", &p[i].x, &p[i].y);
	}
	qsort(p, N, sizeof(p[0]), cmp);
	cnt = 0;
	for (i = 0; i < N; i++)
	{
		pn.x = p[i].x + Dx;
		pn.y = p[i].y + Dy;
		if (NULL == (Point*)bsearch(&pn, p, N, sizeof(pn), cmp))
			continue;
		pn.x = p[i].x;
		pn.y = p[i].y + Dy;
		if (NULL == (Point*)bsearch(&pn, p, N, sizeof(pn), cmp))
			continue;
		pn.x = p[i].x + Dx;
		pn.y = p[i].y;
		if (NULL == (Point*)bsearch(&pn, p, N, sizeof(pn), cmp))
			continue;
		cnt++;
	}
	printf("%d\n", cnt);
}

int main()
{
	while (EOF != scanf("%d", &N))
		Solve();
	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -