1595 - Symmetry

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;

bool compare(pair a,pair b){
	if (a.first == b.first) return a.second < b.second;
	return a.first < b.first;
}

int main(){
	int T;
	cin >> T;
	int N;	
	while (T--){
		cin >> N;
		vector> point;
		set> search;
		double ave_x=0;
		for (int i = 0; i < N; i++){
			pair temp;
			cin >> temp.first >> temp.second;
			ave_x += temp.first;
			point.push_back(temp);
			search.insert(temp);
		}
		sort(point.begin(),point.end(),compare);
		ave_x /= N;
		bool flag = true;
		for (int i = 0; i < N; i++){
			pair temp = point[i];
			pair temp1;
			temp1.second = temp.second;
			temp1.first = 2 * ave_x - temp.first;
			if (search.find(temp1) == search.end()){
				cout << "NO" << endl;
				flag = false;
				break;
			}
		}
		if (flag) cout << "YES" << endl;
	}
	//system("pause");
	return 0;
}

你可能感兴趣的:(Uva,oj)