Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define _test int _TEST; cin>>_TEST; while(_TEST--)
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- _test
- {
- int n;
- cin>>n;
- vector<pair<int, int>> va(n);
- for(auto &[a, b]: va) cin>>a>>b;
- ll int ans = 0;
- map<int, int> cnt[4];
- for(auto [x, y]: va)
- {
- cnt[0][x]++;
- cnt[1][y]++;
- cnt[2][x-y]++;
- cnt[3][x+y]++;
- }
- for(auto [x, y]: va)
- ans += (cnt[0][x] + cnt[1][y] + cnt[2][x-y] + cnt[3][x+y] - 4);
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment