Ankit_132

G

Jul 21st, 2023 (edited)
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8.  
  9. int main()
  10. {
  11.     ios_base::sync_with_stdio(false);
  12.     cin.tie(NULL);
  13.     cout.tie(NULL);
  14.  
  15.     _test
  16.     {
  17.         int n;
  18.         cin>>n;
  19.  
  20.         vector<pair<int, int>> va(n);
  21.         for(auto &[a, b]: va)        cin>>a>>b;
  22.  
  23.         ll int ans = 0;
  24.  
  25.         map<int, int> cnt[4];
  26.  
  27.         for(auto [x, y]: va)
  28.         {
  29.             cnt[0][x]++;
  30.             cnt[1][y]++;
  31.             cnt[2][x-y]++;
  32.             cnt[3][x+y]++;
  33.         }
  34.  
  35.         for(auto [x, y]: va)
  36.             ans += (cnt[0][x] + cnt[1][y] + cnt[2][x-y] + cnt[3][x+y] - 4);
  37.  
  38.         cout<<ans<<"\n";
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment