#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
vector<ll> x_coor(n);
vector<ll> y_coor(n);
vector<pair<ll, ll>> coor(n);
ll x;
ll y;
for(int i=0; i<n; i++)
{
cin>>x>>y;
x_coor[i]=x;
y_coor[i]=y;
coor[i]=make_pair(x, y);
}
sort(x_coor.begin(), x_coor.end());
sort(y_coor.begin(), y_coor.end());
ll ans{};
ll t_x;
ll t_y;
for(auto i: coor)
{
t_x=upper_bound(x_coor.begin(), x_coor.end(), i.first)-lower_bound(x_coor.begin(), x_coor.end(), i.first);
t_y=upper_bound(y_coor.begin(), y_coor.end(), i.second)-lower_bound(y_coor.begin(), y_coor.end(), i.second);
ans+=(t_x-1)*(t_y-1);
}
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
372 KB |
Output is correct |
12 |
Correct |
5 ms |
724 KB |
Output is correct |
13 |
Correct |
6 ms |
844 KB |
Output is correct |
14 |
Correct |
7 ms |
760 KB |
Output is correct |
15 |
Correct |
91 ms |
5488 KB |
Output is correct |
16 |
Correct |
90 ms |
6068 KB |
Output is correct |
17 |
Correct |
81 ms |
5492 KB |
Output is correct |
18 |
Correct |
80 ms |
5604 KB |
Output is correct |
19 |
Correct |
260 ms |
14984 KB |
Output is correct |
20 |
Correct |
170 ms |
10828 KB |
Output is correct |
21 |
Correct |
267 ms |
16156 KB |
Output is correct |
22 |
Correct |
265 ms |
16152 KB |
Output is correct |