Submission #335609

# Submission time Handle Problem Language Result Execution time Memory
335609 2020-12-13T09:28:24 Z StanCatalin Star triangles (IZhO11_triangle) C++14
0 / 100
1 ms 364 KB
#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
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -