Submission #153188

# Submission time Handle Problem Language Result Execution time Memory
153188 2019-09-12T19:37:57 Z Ruxandra985 popa (BOI18_popa) C++14
100 / 100
101 ms 436 KB
#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 time Memory Grader output
1 Correct 7 ms 248 KB Output is correct
2 Correct 19 ms 376 KB Output is correct
3 Correct 13 ms 376 KB Output is correct
4 Correct 24 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 78 ms 376 KB Output is correct
2 Correct 98 ms 312 KB Output is correct
3 Correct 64 ms 376 KB Output is correct
4 Correct 84 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 84 ms 436 KB Output is correct
2 Correct 53 ms 316 KB Output is correct
3 Correct 83 ms 312 KB Output is correct
4 Correct 101 ms 312 KB Output is correct