Submission #312985

#TimeUsernameProblemLanguageResultExecution timeMemory
312985thecodingwizardpopa (BOI18_popa)C++11
37 / 100
304 ms504 KiB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;

int solve(int N, int *L, int *R) {
    for (int i = 0; i < N; i++) {
        L[i] = R[i] = -1;
    }
    int root = -1;
    for (int i = 0; i < N; i++) {
        if (root == -1) {
            root = i;
            continue;
        }
        if (query(0, i, i, i)) {
            L[i] = root;
            root = i;
            continue;
        }
        int cur = root;
        while (R[cur] != -1) {
            if (query(R[cur], i, i, i)) {
                break;
            }
            cur = R[cur];
        }
        if (R[cur] != -1) {
            L[i] = R[cur];
        }
        R[cur] = i;
    }
    return root;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...