#include <bits/stdc++.h>
#define inf 1000000007
#define N 1000007
#define pb push_back
#define ss second
#define ff first
#define pii pair<ll,ll>
#define ll long long
using namespace std;
const int maxn = 3e5+5;
ll n,ans;
pii a[maxn];
map<ll, ll> m,k;
int main() {
cin >> n;
for (int i = 1; i <= n; ++i){
cin >> a[i].ff >> a[i].ss;
m[a[i].ff]++;
k[a[i].ss]++;
}
for (int i = 1; i <= n; ++i){
ans += (m[a[i].ff] - 1) * (k[a[i].ss] - 1);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
2 ms |
364 KB |
Output is correct |
12 |
Correct |
12 ms |
1260 KB |
Output is correct |
13 |
Correct |
14 ms |
1388 KB |
Output is correct |
14 |
Correct |
18 ms |
1772 KB |
Output is correct |
15 |
Correct |
279 ms |
7916 KB |
Output is correct |
16 |
Correct |
243 ms |
8320 KB |
Output is correct |
17 |
Correct |
229 ms |
8000 KB |
Output is correct |
18 |
Correct |
224 ms |
8044 KB |
Output is correct |
19 |
Correct |
638 ms |
14700 KB |
Output is correct |
20 |
Correct |
443 ms |
11884 KB |
Output is correct |
21 |
Correct |
684 ms |
15724 KB |
Output is correct |
22 |
Correct |
700 ms |
15724 KB |
Output is correct |