#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define ll long long
#define ld long double
#define fs first
#define sc second
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define sz(x) (int)(x).size()
#define int long long
#define all(x) x.begin(), x.end()
int gcd(int a,int b){
return b==0?a:gcd(b,a%b);
}
int lcm(int a,int b){
return a*b/gcd(a,b);
}
const int mod =1e9+7;
const ll N = 3e5 + 9;
unordered_map<ll,ll> mpx,mpy;
int n,ans;
pair<int ,int >a[N];
int32_t main() {
IOS;
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].fs>>a[i].sc;
mpx[a[i].fs]++;
mpy[a[i].sc]++;
}
int ans=0;
for (int i = 1;i <= n;i++){
int p = mpx[a[i].fs] - 1,q = mpy[a[i].sc] - 1;
ans+=p*q;
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 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 |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
5 ms |
1020 KB |
Output is correct |
13 |
Correct |
7 ms |
972 KB |
Output is correct |
14 |
Correct |
7 ms |
1356 KB |
Output is correct |
15 |
Correct |
61 ms |
6596 KB |
Output is correct |
16 |
Correct |
64 ms |
6900 KB |
Output is correct |
17 |
Correct |
52 ms |
6564 KB |
Output is correct |
18 |
Correct |
53 ms |
6668 KB |
Output is correct |
19 |
Correct |
132 ms |
13244 KB |
Output is correct |
20 |
Correct |
141 ms |
10472 KB |
Output is correct |
21 |
Correct |
147 ms |
14104 KB |
Output is correct |
22 |
Correct |
168 ms |
14244 KB |
Output is correct |