#include <bits/stdc++.h>
using namespace std;
const int maxN = 3e5+7;
int main(){
int q; cin >> q;
long long x[maxN], y[maxN];
map<int, int> cntX, cntY;
for(int i = 0; i < q; i++)
{
cin >> x[i] >> y[i];
cntX[x[i]]++;
cntY[y[i]]++;
}
long long ans = 0;
for(int i = 0; i < q; i++){
ans += (cntX[x[i]] - 1) * (cntY[y[i]] - 1);
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4956 KB |
Output is correct |
2 |
Correct |
3 ms |
4984 KB |
Output is correct |
3 |
Correct |
2 ms |
4952 KB |
Output is correct |
4 |
Correct |
3 ms |
4956 KB |
Output is correct |
5 |
Correct |
4 ms |
5208 KB |
Output is correct |
6 |
Correct |
3 ms |
4956 KB |
Output is correct |
7 |
Correct |
3 ms |
4952 KB |
Output is correct |
8 |
Correct |
3 ms |
4956 KB |
Output is correct |
9 |
Correct |
3 ms |
4956 KB |
Output is correct |
10 |
Correct |
3 ms |
4956 KB |
Output is correct |
11 |
Correct |
3 ms |
4956 KB |
Output is correct |
12 |
Correct |
10 ms |
5724 KB |
Output is correct |
13 |
Correct |
11 ms |
5724 KB |
Output is correct |
14 |
Correct |
14 ms |
5980 KB |
Output is correct |
15 |
Correct |
129 ms |
10180 KB |
Output is correct |
16 |
Correct |
168 ms |
10320 KB |
Output is correct |
17 |
Correct |
125 ms |
9964 KB |
Output is correct |
18 |
Correct |
126 ms |
10024 KB |
Output is correct |
19 |
Correct |
364 ms |
14004 KB |
Output is correct |
20 |
Correct |
263 ms |
12224 KB |
Output is correct |
21 |
Correct |
391 ms |
14164 KB |
Output is correct |
22 |
Correct |
366 ms |
14320 KB |
Output is correct |