fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <unordered_set>
  4. using namespace std;
  5. int t, n, x, y;
  6.  
  7. struct hashFunction {
  8. size_t operator()(const pair<int,int> &x) const {
  9. return x.first ^ x.second;
  10. }
  11. };
  12.  
  13. vector<pair<int, int> > vec;
  14.  
  15. int main() {
  16. scanf("%d", &t);
  17. while(t--) {
  18. vec.clear();
  19. unordered_set<pair<int, int>, hashFunction> left;
  20. unordered_set<pair<int, int>, hashFunction> right;
  21. scanf("%d", &n);
  22. int min = 10005, max = -10005;
  23. for (int i = 0; i < n; i++) {
  24. scanf("%d%d", &x, &y);
  25. vec.emplace_back(make_pair(x, y));
  26. if (x < min) min = x;
  27. if (x > max) max = x;
  28. }
  29. double mid = (double)(min + max) / 2;
  30. for (auto &it : vec) {
  31. if (it.first < mid) left.insert(it);
  32. else if (it.first > mid) right.insert(it);
  33. }
  34. if (left.size() != right.size()) printf("NO\n");
  35. else {
  36. bool f = true;
  37. for (auto &it : left) {
  38. int rightX = (min + max) - it.first;
  39. pair<int, int> rightMatch = make_pair(rightX, it.second);
  40. if (right.find(rightMatch) == right.end()) {
  41. f = false;
  42. break;
  43. }
  44. }
  45. if (f) printf("YES\n");
  46. else printf("NO\n");
  47. }
  48. }
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5460KB
stdin
3
5
-2 5
0 0
6 5
4 0
2 3
4
2 3
0 4
4 0
0 0
4
5 14
6 10
5 10
6 14
stdout
YES
NO
YES