#include <bits/stdc++.h>
typedef long double ld;
#define int long long
#define TC int t; cin >> t; for(int _=1; _<=t; _++)
#define pii pair<int, int>
#define pb push_back
#define ffl fflush(stdout)
using namespace std;
signed main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n; cin >> n;
map<int, int> mapx, mapy;
vector<pii> res;
for(int i=0; i<n; i++){
int x, y; cin >> x >> y;
mapx[x]++;
mapy[y]++;
res.pb(make_pair(x, y));
}
int ans = 0;
for(int i=0; i<n; i++){
int x = res[i].first, y = res[i].second;
int cntx = mapx[x]-1;
int cnty = mapy[y]-1;
if(cntx>0 && cnty>0){
ans+=(cntx*cnty);
}
}
cout << ans;
//cout << (4*(99*99)) + 200;
//cout << 99*99;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
1240 KB |
Output is correct |
13 |
Correct |
5 ms |
1240 KB |
Output is correct |
14 |
Correct |
8 ms |
1628 KB |
Output is correct |
15 |
Correct |
88 ms |
5928 KB |
Output is correct |
16 |
Correct |
103 ms |
6028 KB |
Output is correct |
17 |
Correct |
88 ms |
5820 KB |
Output is correct |
18 |
Correct |
90 ms |
5804 KB |
Output is correct |
19 |
Correct |
239 ms |
12728 KB |
Output is correct |
20 |
Correct |
190 ms |
9180 KB |
Output is correct |
21 |
Correct |
271 ms |
13788 KB |
Output is correct |
22 |
Correct |
254 ms |
12724 KB |
Output is correct |