#include<bits/stdc++.h>
#define int long long
#define INF 1e9
#define pb push_back
using namespace std;
void solve(){
int n; cin >> n;
vector<pair<int,int>> v;
map<int,int> x,y;
for(int i=0; i < n; i ++){
int q,w; cin >> q >> w;
v.pb({q,w});
x[q]++; y[w] ++;
// y[q]++; x[w] ++;
}
int s = 0;
for(auto i : v){
s += (x[i.first] - 1) * (y[i.second] - 1);
}
cout << s;
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
cout.tie(0)->sync_with_stdio(0);
int t;
t=1;
// cin >> t;
while(t--){
solve();
cout << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 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 |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
5 ms |
1312 KB |
Output is correct |
13 |
Correct |
5 ms |
1372 KB |
Output is correct |
14 |
Correct |
9 ms |
1748 KB |
Output is correct |
15 |
Correct |
89 ms |
8052 KB |
Output is correct |
16 |
Correct |
94 ms |
8212 KB |
Output is correct |
17 |
Correct |
91 ms |
7984 KB |
Output is correct |
18 |
Correct |
93 ms |
7872 KB |
Output is correct |
19 |
Correct |
239 ms |
20480 KB |
Output is correct |
20 |
Correct |
176 ms |
11972 KB |
Output is correct |
21 |
Correct |
272 ms |
19624 KB |
Output is correct |
22 |
Correct |
263 ms |
20152 KB |
Output is correct |