记录编号 294438 评测结果 AAAAAAAAAA
题目名称 [HZOI 2016]几何 最终得分 100
用户昵称 GravatarTiny 是否通过 通过
代码语言 C++ 运行时间 3.703 s
提交时间 2016-08-12 06:39:29 内存使用 0.22 MiB
显示代码纯文本
#include "stdio.h"
#include "stdlib.h"
#include "map"
#include "iostream"
#include "vector"
using namespace std;

template <class T> inline void QR(T& num) {
	num = 0; char ch; short flag = 1;
	while (ch = getchar(), ch<'-' || ch>'9');
	if (ch == '-') flag = -1, ch = getchar();
	while (num = num * 10 + ch - 48, ch = getchar(), ch >= '0'&&ch <= '9');
	num *= flag;
}

#define SUBMIT

//struct Point {
//	int x, y;
//	bool operator<(const Point& b) {
//		if (x < b.x) return 1;
//		else if (x > b.x) return 0;
//		return 
//	}
//};

map<pair<int, int>, bool> m;

pair<int, int> P[1010];

int main() {
#ifdef SUBMIT
	freopen("geometry.in", "r", stdin);
	freopen("geometry.out", "w", stdout);
#endif

	int t; QR<int>(t);
	while (t--) {
		m.clear();
		int n; QR<int>(n);
		for (int i = 1; i <= n; ++i) {
			int x, y; QR<int>(x), QR<int>(y);
			m[P[i] = make_pair(x, y)] = 1;
		}
		for (int i = 1; i <= n; ++i) for (int j = i + 1; j <= n; ++j) {
			int xa = P[i].first, ya = P[i].second, xb = P[j].first, yb = P[j].second;
			int dx = abs(P[i].first - P[j].first), dy = abs(P[i].second - P[j].second);
			if ((m.count(make_pair(xa + dy, ya + dx)) && m.count(make_pair(xb + dy, yb + dx))) || (m.count(make_pair(xa - dy, ya - dx)) && m.count(make_pair(xb - dy, yb - dx)))) goto BREAK;
		}
		printf("-1\n"); goto NEXT;
		BREAK:printf("4\n");
		NEXT:;
	}

#ifndef SUBMIT
	puts("\n---------------------");
	getchar(), getchar();
#else
	fclose(stdin), fclose(stdout);
#endif
	return 0;
}