#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define f first
#define s second
#define mp make_pair
#define pb push_back
const int N = 3e5 + 5;
const int INF = 1e18;
int x[N], y[N];
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
int n;
cin>>n;
int ans = 0;
for(int i = 1;i <= n;i++){
cin >> x[i] >> y[i];
}
set< pii> se;
map<int,int> cntx, cnty;
map<pii, int> lol;
for(int i= 1;i <= n;i++){
cntx[x[i]] ++;
cnty[y[i]] ++;
lol[mp(x[i], y[i])] ++;
}
for(int i = 1;i <= n;i++){
// if(se.count(mp(x[i], y[i]))) continue;
int a = x[i], b = y[i];
// (a, b2)
// (a, b) (a2, b)
// find number of points such that x = a
// find number of points such that y = b
ans += ((cntx[a] - 1) * (cnty[b] - 1));
se.insert(mp(a, b));
}
cout <<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
460 KB |
Output is correct |
12 |
Correct |
11 ms |
2252 KB |
Output is correct |
13 |
Correct |
10 ms |
2252 KB |
Output is correct |
14 |
Correct |
15 ms |
2764 KB |
Output is correct |
15 |
Correct |
237 ms |
18320 KB |
Output is correct |
16 |
Correct |
320 ms |
19544 KB |
Output is correct |
17 |
Correct |
238 ms |
20460 KB |
Output is correct |
18 |
Correct |
285 ms |
20420 KB |
Output is correct |
19 |
Correct |
868 ms |
49524 KB |
Output is correct |
20 |
Correct |
627 ms |
36912 KB |
Output is correct |
21 |
Correct |
992 ms |
53104 KB |
Output is correct |
22 |
Correct |
944 ms |
53060 KB |
Output is correct |