#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
using namespace std;
typedef struct Pos
{
int x;
int y;
bool operator < (const Pos& p) const { {}
return x > p.x;
}
bool operator == (const Pos& p) const { {}
return x == p.x&&y==p.y;
}
}Pos;
int main()
{
int T;cin >> T;
while (T--)
{
int N;cin >> N;
vector<Pos> v;
while (N--)
{
int x, y;cin >> x >> y;
Pos p = { 2*x,2*y };
v.push_back(p);
}
int len = v.size();
sort(v.begin(), v.end());
int sym = (v[0].x + v[len-1].x) / 2;
bool flag=true;
for (int i = 0;i < len;i++)
{
if (v[i].x == sym)continue;
Pos p = { sym - v[i].x + sym,v[i].y };
if (find(v.begin(), v.end(), p) == v.end()) { flag = false;break; }
}
printf("%s\n", flag ? "YES" : "NO");
}
return 0;
}
暴力,对称轴肯定是最右端和最左端的两个点之间,所以直接找到对称点,然后检查其他的点是否都一一对称。为了避免处理小数,所以事先将所有的坐标乘以2
UVA 1595
最新推荐文章于 2024-04-09 19:27:05 发布