#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<long long, long long>
using namespace std;
void solve(){
ll n;
cin >> n;
map<ll,ll> x;
map<ll,ll> y;
vector<pll> v;
for(int i=1;i<=n;i++){
ll a,b;
cin >> a >> b;
x[a]++;
y[b]++;
v.pb({a,b});
}
ll ans = 0;
for(auto i:v){
ans += (x[i.fi]-1) * (y[i.se]-1);
}
cout << ans << endl;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tc = 1;
// cin >> tc;
while(tc--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
456 KB |
Output is correct |
6 |
Correct |
1 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 |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
8 ms |
1372 KB |
Output is correct |
13 |
Correct |
5 ms |
1356 KB |
Output is correct |
14 |
Correct |
10 ms |
1752 KB |
Output is correct |
15 |
Correct |
91 ms |
7108 KB |
Output is correct |
16 |
Correct |
104 ms |
7616 KB |
Output is correct |
17 |
Correct |
86 ms |
7020 KB |
Output is correct |
18 |
Correct |
99 ms |
7188 KB |
Output is correct |
19 |
Correct |
235 ms |
17152 KB |
Output is correct |
20 |
Correct |
180 ms |
11616 KB |
Output is correct |
21 |
Correct |
277 ms |
16984 KB |
Output is correct |
22 |
Correct |
260 ms |
16540 KB |
Output is correct |