#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fs first
#define sc second
int main(){
int n;
cin>>n;
multiset<pair<int,int>> p;
multiset<int> mx,my;
while (n--) {
int x,y;
cin>>x>>y;
p.insert({x,y});
mx.insert(x);my.insert(y);
}
ll cnt=0;
for (auto [x,y]:p){
ll a=mx.count(x)-p.count({x,y}),b=my.count(y)-p.count({x,y});
cnt+=a*b;
}
cout<<cnt;
}
# |
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 |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
2 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
408 KB |
Output is correct |
12 |
Correct |
64 ms |
1968 KB |
Output is correct |
13 |
Correct |
246 ms |
2032 KB |
Output is correct |
14 |
Correct |
14 ms |
1884 KB |
Output is correct |
15 |
Correct |
220 ms |
16584 KB |
Output is correct |
16 |
Correct |
240 ms |
17880 KB |
Output is correct |
17 |
Correct |
198 ms |
16468 KB |
Output is correct |
18 |
Correct |
212 ms |
16476 KB |
Output is correct |
19 |
Correct |
1080 ms |
44884 KB |
Output is correct |
20 |
Correct |
630 ms |
32300 KB |
Output is correct |
21 |
Correct |
1270 ms |
48464 KB |
Output is correct |
22 |
Correct |
1211 ms |
48316 KB |
Output is correct |