Uva


假设对称轴存在,先把横坐标加起来求和平均得到对称轴,然后遍历每个点,通过对称轴求得对称点,看是否存在。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <stack>
#include <queue>

using namespace std;

typedef pair<int, int> point;

int main()
{
	ios::sync_with_stdio(false);
	int T;
	cin >> T;
	while (T--) {
		set<point> data;
		int n;
		point p;
		int sum = 0;
		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> p.first >> p.second;
			sum += p.first;
			data.insert(point(p.first * n, p.second));
		}
		bool flag = true;
		for (set<point>::iterator it = data.begin(); it != data.end(); it++) {
			point p = *it;
			if (data.find(point(2 * sum - p.first, p.second)) == data.end()) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << "YES
";
		}
		else {
			cout << "NO
";
		}

	}
	return 0;
}




原文地址:https://www.cnblogs.com/zhangyaoqi/p/4591586.html