#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define mp make_pair
const long long mx=3e5+5;
// FREOPEN UNUTMA
long long n;
pair <long long,long long> a[mx];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
/*freopen("triangles.in", "r", stdin);
freopen("triangles.out", "w", stdout); */
//
unordered_multimap <long long,long long> mp;
unordered_multimap <long long,long long> mp2;
cin >> n;
rep(i,n){
cin >> a[i].first;
cin >> a[i].second;
mp.insert(pair <long long,long long>(a[i].first,a[i].nd));
mp2.insert(pair<long long,long long>(a[i].nd,a[i].st));
}
long long ans=0;
for(long long i=0;i<n;++i){
ans+=(mp.count(a[i].first)-1)*(mp2.count(a[i].nd)-1);
// cout << mp.count(a[i].first) <<" "<< mp2.count(a[i].nd)<< endl;
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
376 KB |
Output is correct |
11 |
Correct |
8 ms |
504 KB |
Output is correct |
12 |
Correct |
159 ms |
1400 KB |
Output is correct |
13 |
Correct |
590 ms |
1528 KB |
Output is correct |
14 |
Correct |
11 ms |
1528 KB |
Output is correct |
15 |
Correct |
161 ms |
11468 KB |
Output is correct |
16 |
Correct |
199 ms |
14628 KB |
Output is correct |
17 |
Correct |
170 ms |
11472 KB |
Output is correct |
18 |
Correct |
173 ms |
11448 KB |
Output is correct |
19 |
Correct |
1216 ms |
30228 KB |
Output is correct |
20 |
Correct |
646 ms |
20664 KB |
Output is correct |
21 |
Correct |
1343 ms |
32020 KB |
Output is correct |
22 |
Correct |
1351 ms |
32016 KB |
Output is correct |