pku2526.cpp

来自「这是ACM 方面的资料 是PKU的 北京大学的出来的」· C++ 代码 · 共 56 行

CPP
56
字号
#include <stdio.h>
#include <stdlib.h>

typedef struct point
{
	int x, y;
}Point;

Point p[10001];

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

int main()
{
	int T, N, i, x, y;
	Point tmp, *pp;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d", &N);
		for (i = 0; i < N; i++)
		{
			scanf("%d %d", &p[i].x, &p[i].y);
		}
		qsort(p, N, sizeof(p[0]), cp);
		x = p[0].x + p[N - 1].x;
		y = p[0].y + p[N - 1].y;
		for (i = 1; i < N - 1; i++)
		{
			tmp.x = x - p[i].x;
			tmp.y = y - p[i].y;
			pp = (Point *)bsearch(&tmp, p, N, sizeof(p[0]), cp);
			if (pp == NULL)
			{
				printf("no\n");
				break;
			}
		}
		if (i == N - 1)
		{
			printf("yes\n");
		}
	}
	return 0;
}

⌨️ 快捷键说明

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