Submission #249427

# Submission time Handle Problem Language Result Execution time Memory
249427 2020-07-15T02:00:48 Z thebes popa (BOI18_popa) C++14
100 / 100
128 ms 496 KB
#include "popa.h"
#include <bits/stdc++.h>
using namespace std;

const int MN = 1005;
int i, cur, par[MN];

int solve(int N,int *L,int *R){
    cur = 0;
    for(i=0;i<N;i++)
        par[i]=L[i]=R[i]=-1;
    for(i=1;i<N;i++){
        if(query(cur,i,i,i)){
            if(par[cur]==-1){
                L[i] = cur;
                par[cur] = i;
                cur = i;
            }
            else{
                cur = par[cur];
                i--;
            }
        }
        else{
            if(~R[cur]){
                L[i]=R[cur];
                par[L[i]]=i;
            }
            R[cur] = i;
            par[i] = cur;
            cur = i;
        }
    }
    while(~par[cur]) cur=par[cur];
    return cur;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 256 KB Output is correct
2 Correct 7 ms 256 KB Output is correct
3 Correct 9 ms 256 KB Output is correct
4 Correct 11 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 86 ms 384 KB Output is correct
2 Correct 105 ms 384 KB Output is correct
3 Correct 66 ms 496 KB Output is correct
4 Correct 88 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 128 ms 384 KB Output is correct
2 Correct 85 ms 496 KB Output is correct
3 Correct 86 ms 384 KB Output is correct
4 Correct 93 ms 376 KB Output is correct