fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <cassert>
  4. #include <climits>
  5. #include <map>
  6. using namespace std;
  7.  
  8. #define pii pair<int, int>
  9.  
  10. int main() {
  11. cin.tie(0)->sync_with_stdio(0);
  12. int t; cin >> t;
  13. while (t--) {
  14. int n; cin >> n;
  15. vector<pii> a(n);
  16. map<int, int> mp1, mp2; //x + y, x
  17.  
  18. for (auto &[x, y] : a) {
  19. cin >> x >> y;
  20. mp1[x + y]++;
  21. mp2[x]++;
  22. }
  23.  
  24. int s = -1, c = -1; // c = x + y
  25. for (auto [x, cnt] : mp2) {
  26. if (cnt & 1) {
  27. s = x;
  28. break;
  29. }
  30. }
  31.  
  32. for (auto [b, cnt] : mp1) {
  33. if (cnt & 1) {
  34. c = b;
  35. break;
  36. }
  37. }
  38.  
  39. cout << s << " " << c - s << '\n';
  40. }
  41. }
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
Success #stdin #stdout 0s 5312KB
stdin
4
1
2 3
3
-2 -1
-1 -2
-1 -3
7
7 26
6 27
6 28
7 27
8 26
8 27
7 28
11
70 9
69 8
69 0
73 5
70 -1
70 5
71 7
70 4
73 4
71 3
72 3
stdout
2 3
-2 -2
7 27
72 7