Submission #978426

# Submission time Handle Problem Language Result Execution time Memory
978426 2024-05-09T08:12:58 Z alexdd popa (BOI18_popa) C++17
Compilation error
0 ms 0 KB
int myquery(int a, int b, int c, int d)
{
    return query(min(a,b),max(a,b),min(c,d),max(c,d));
}
vector<int> ord;
void precalc(int limle[1005])
{
    for(int i=0;i<ord.size();i++)
    {
        int st=0,dr=i,ans=i;
        while(st<=dr)
        {
            int mij=(st+dr)/2;
            if(myquery(ord[mij],ord[i],ord[i],ord[i]))
            {
                ans=mij;
                dr=mij-1;
            }
            else
                st=mij+1;
        }
        limle[ord[i]] = ord[ans];
    }
}
int tole[1005],tori[1005];
int limle[1005],limri[1005];
int calc(int le, int ri)
{
    if(le>ri)
        return -1;
    if(le==ri)
    {
        tole[le]=tori[le]=-1;
        return le;
    }
    for(int root=le;root<=ri;root++)
    {
        if(limle[root]<=le && limri[root]>=ri)
        {
            tole[root] = calc(le,root-1);
            tori[root] = calc(root+1,ri);
            return root;
        }
    }
    return -5;
}
int solve(int N, int* Left, int* Right)
{
    ord.clear();
    for(int i=0;i<N;i++)
        ord.push_back(i);
    precalc(limle);
    reverse(ord.begin(),ord.end());
    precalc(limri);
    //for(int i=0;i<N;i++) cout<<i<<"  "<<limle[i]<<" "<<limri[i]<<" lim\n";
    for(int i=0;i<N;i++)
        tole[i]=tori[i]=-1;
    int root = calc(0,N-1);
    for(int i=0;i<N;i++)
    {
        Left[i]=tole[i];
        Right[i]=tori[i];
    }
    return root;
}

Compilation message

popa.cpp: In function 'int myquery(int, int, int, int)':
popa.cpp:3:18: error: 'min' was not declared in this scope
    3 |     return query(min(a,b),max(a,b),min(c,d),max(c,d));
      |                  ^~~
popa.cpp:3:27: error: 'max' was not declared in this scope
    3 |     return query(min(a,b),max(a,b),min(c,d),max(c,d));
      |                           ^~~
popa.cpp:3:12: error: 'query' was not declared in this scope; did you mean 'myquery'?
    3 |     return query(min(a,b),max(a,b),min(c,d),max(c,d));
      |            ^~~~~
      |            myquery
popa.cpp: At global scope:
popa.cpp:5:1: error: 'vector' does not name a type
    5 | vector<int> ord;
      | ^~~~~~
popa.cpp: In function 'void precalc(int*)':
popa.cpp:8:19: error: 'ord' was not declared in this scope
    8 |     for(int i=0;i<ord.size();i++)
      |                   ^~~
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:49:5: error: 'ord' was not declared in this scope
   49 |     ord.clear();
      |     ^~~
popa.cpp:53:5: error: 'reverse' was not declared in this scope
   53 |     reverse(ord.begin(),ord.end());
      |     ^~~~~~~