Submission #445842

# Submission time Handle Problem Language Result Execution time Memory
445842 2021-07-19T20:35:32 Z simon2712 Star triangles (IZhO11_triangle) C++14
0 / 100
2000 ms 204 KB
#include <bits/stdc++.h>
using namespace std;
ifstream fin("triangles.in");
ofstream fout("triangles.out");
pair<int,int> v[3000001];
int main()
{
    long long n,i,st,rez,dr,mij,st2,dr2,st3,dr3;
    fin>>n;
    for(i=1;i<=n;i++)
        fin>>v[i].first>>v[i].second;
    sort(v+1,v+n+1);
    for(i=1;i<=n;i++)
    {
        st=1;
        dr=n;
        while(st<=dr)
        {
            mij=(st+dr)/2;
            if(v[mij].first<=v[i].first)
                st=mij+1;
            else
                dr=mij-1;
        }
        st2=st-1;
        st=1;
        dr=n;
        while(st<=dr)
        {
            mij=(st+dr)/2;
            if(v[mij].first>=v[i].first)
                dr=mij-1;
            else
                st=mij+1;
        }
        dr2=dr+1;
        st=1;
        dr=n;
        while(st<=dr)
        {
            mij=(st+dr)/2;
            if(v[mij].second>=v[i].second)
                dr=mij-1;
            else
                st=mij+1;
        }
        dr3=dr+1;
        st=1;
        dr=n;
        while(st<=dr)
        {
            mij=(st+dr)/2;
            if(v[mij].second<=v[i].second)
                st=mij+1;
            else
                dr=mij-1;
        }
        st3=st-1;
        rez+=(dr3-st3)*(dr2-st2);
    }
    fout<<rez;
    return 0;
}

Compilation message

triangle.cpp: In function 'int main()':
triangle.cpp:59:12: warning: 'rez' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |         rez+=(dr3-st3)*(dr2-st2);
      |         ~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2079 ms 204 KB Time limit exceeded
2 Halted 0 ms 0 KB -