Submission #153188

#TimeUsernameProblemLanguageResultExecution timeMemory
153188Ruxandra985popa (BOI18_popa)C++14
100 / 100
101 ms436 KiB
#include <cstdio>
#include "popa.h"


int solve (int N , int *Left , int *Right){ /// return root
    int i,root,u;
    int st[1010];
    for (i=0;i<N;i++){
        Left[i] = Right[i] = -1; /// reset all
    }
    /// primul e clar frunza

    u = 1;
    st[1] = 0;
    root = 0;

    for (i=1;i<N;i++){
        while (u && query (st[u],i,i,i)){
            u--;
        }
        if (u){ /// nu dev root
            Left[i] = Right[st[u]];
            Right[st[u]] = i;
        }
        else {
            Left[i] = root;
            root = i;
        }
        st[++u] = i;
    }


    return root;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...