Submission #312985

# Submission time Handle Problem Language Result Execution time Memory
312985 2020-10-14T22:07:06 Z thecodingwizard popa (BOI18_popa) C++11
37 / 100
304 ms 504 KB
#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 time Memory Grader output
1 Correct 55 ms 256 KB Output is correct
2 Correct 121 ms 384 KB Output is correct
3 Correct 19 ms 256 KB Output is correct
4 Correct 54 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 304 ms 504 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 256 KB too many queries
2 Halted 0 ms 0 KB -