#include <bits/stdc++.h>
#define ll long long
#define MAXN 300010
using namespace std;
map<ll,ll> cntx,cnty;
ll x[MAXN],y[MAXN];
int main()
{
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n;
cin >> n;
for (ll i=1;i<=n;i++)
{
cin >> x[i] >> y[i];
cntx[x[i]]++;
cnty[y[i]]++;
}
ll ans=0;
for (ll i=1;i<=n;i++)
ans+=(cntx[x[i]]-1)*(cnty[y[i]]-1);
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2756 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2512 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
5 ms |
3164 KB |
Output is correct |
13 |
Correct |
5 ms |
3364 KB |
Output is correct |
14 |
Correct |
8 ms |
3880 KB |
Output is correct |
15 |
Correct |
84 ms |
10784 KB |
Output is correct |
16 |
Correct |
99 ms |
11024 KB |
Output is correct |
17 |
Correct |
96 ms |
10676 KB |
Output is correct |
18 |
Correct |
89 ms |
10700 KB |
Output is correct |
19 |
Correct |
241 ms |
15048 KB |
Output is correct |
20 |
Correct |
190 ms |
13004 KB |
Output is correct |
21 |
Correct |
255 ms |
15700 KB |
Output is correct |
22 |
Correct |
256 ms |
15700 KB |
Output is correct |