# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
676200 | Toxtaq | Star triangles (IZhO11_triangle) | C++17 | 2082 ms | 4152 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
int main()
{
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 |
---|---|---|---|---|
Fetching results... |