# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335609 | StanCatalin | Star triangles (IZhO11_triangle) | C++14 | 1 ms | 364 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 <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream in("triangles.in");
ofstream out("triangles.out");
const int dim = 3e5 + 5;
int n,vec1[dim],vec2[dim],vec3[dim],vec4[dim];
pair<int,int> a[dim];
int main()
{
in >> n;
for (int i=1; i<=n; i++)
{
in >> a[i].first >> a[i].second;
}
sort(a+1,a+n+1);
for (int i=1; i<=n; i++)
{
vec1[a[i].second]++;
vec4[a[i].first]++;
}
for (int i=n; i>=1; i--)
{
vec2[a[i].second]++;
vec3[a[i].first]++;
}
int ans = 0;
for (int i=1; i<=n; i++)
{
int x = a[i].first;
int y = a[i].second;
ans += (vec4[x] - 1) * (vec1[y] - 1) + (vec4[x] - 1) * (vec3[y] - 1) + (vec2[x] - 1) * (vec3[y] - 1) + (vec2[x] - 1) * (vec1[y] - 1);
}
out << ans/4;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |