#include<bits/stdc++.h>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int>x(n), y(n);
for(int i = 0;i < n;++i){
cin >> x[i] >> y[i];
}
vector<pair<int, int>>pairs(n);
for(int i = 0;i < n;++i){
pairs[i] = {x[i], i};
}
sort(pairs.begin(), pairs.end());
int nxt = 0;
for(int i = 0;i < n;++i){
if(i > 0 && pairs[i - 1].first != pairs[i].first)nxt++;
x[pairs[i].second] = nxt;
}
for(int i = 0;i < n;++i){
pairs[i] = {y[i], i};
}
sort(pairs.begin(), pairs.end());
nxt = 0;
for(int i = 0;i < n;++i){
if(i > 0 && pairs[i - 1].first != pairs[i].first)nxt++;
y[pairs[i].second] = nxt;
}
vector<int>X(300001), Y(300001);
for(int i = 0;i < n;++i){
X[x[i]]++;
Y[y[i]]++;
}
int result = 0;
for(int i = 0;i < n;++i){
if(Y[y[i]] < 2)continue;
Y[y[i]]--;
for(int j = i + 1;j < n;++j){
if(y[i] == y[j])result += X[x[i]] + X[x[j]] - 2;
}
}
cout << result;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2644 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
1 ms |
2644 KB |
Output is correct |
5 |
Correct |
1 ms |
2644 KB |
Output is correct |
6 |
Correct |
1 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2644 KB |
Output is correct |
9 |
Correct |
2 ms |
2644 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
2 ms |
2644 KB |
Output is correct |
12 |
Correct |
5 ms |
2832 KB |
Output is correct |
13 |
Correct |
20 ms |
2772 KB |
Output is correct |
14 |
Correct |
13 ms |
2772 KB |
Output is correct |
15 |
Execution timed out |
2072 ms |
4196 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |