#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define forn(i,n) for(int i = 1; i<=n; i++)
#define fi first
#define sc second
using namespace std;
int main(){
map<ll,ll> mpx,mpy;
map<pair<ll,ll>, ll> mpdup;
ll n;
cin >> n;
pair<ll,ll> arr[n+99];
forn(i,n){
ll x,y;
cin >> x >> y;
mpx[x]++;
mpy[y]++;
mpdup[{x,y}]++;
arr[i] = {x,y};
}
ll sum = 0;
forn(i,n){
ll x = arr[i].fi,y = arr[i].sc;
if(mpdup[{x,y}] == 0)continue;
ll dup = mpdup[{x,y}];
if(mpdup[{x,y}] == 1){
sum += (mpx[x]-1) * (mpy[y]-1);
}else{
sum += (mpx[x] - dup )*(mpy[y] - dup )*(dup);
}
mpdup[{x,y}] = 0;
}
cout<<sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
1 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 |
2 ms |
348 KB |
Output is correct |
12 |
Correct |
14 ms |
1748 KB |
Output is correct |
13 |
Correct |
14 ms |
1884 KB |
Output is correct |
14 |
Correct |
18 ms |
2396 KB |
Output is correct |
15 |
Correct |
247 ms |
14080 KB |
Output is correct |
16 |
Correct |
266 ms |
15188 KB |
Output is correct |
17 |
Correct |
266 ms |
14288 KB |
Output is correct |
18 |
Correct |
249 ms |
14072 KB |
Output is correct |
19 |
Correct |
791 ms |
32588 KB |
Output is correct |
20 |
Correct |
508 ms |
24460 KB |
Output is correct |
21 |
Correct |
940 ms |
34444 KB |
Output is correct |
22 |
Correct |
911 ms |
34548 KB |
Output is correct |