Submission #61246

# Submission time Handle Problem Language Result Execution time Memory
61246 2018-07-25T13:15:18 Z SpaimaCarpatilor popa (BOI18_popa) C++17
37 / 100
250 ms 532 KB
#include<bits/stdc++.h>
#include "popa.h"

using namespace std;

static int nxt[2018];

int solve (int l, int r, int *Left, int *Right)
{
    if (l > r) return -1;
    if (l == r)
        return l;
    if (r == l + 1)
    {
        if (query (l, l, l, r))
        {
            Right[l] = r;
            return l;
        }
        Left[r] = l;
        return r;
    }
    int pos = l;
    while (nxt[pos] <= r)
        pos = nxt[pos];
    int ras = pos;
    Left[ras] = solve (l, ras - 1, Left, Right);
    Right[ras] = solve (ras + 1, r, Left, Right);
    return ras;
}

int solve (int nn, int* Left, int* Right)
{
    int N = nn;
    for (int i=0; i<N; i++)
        Left[i] = Right[i] = -1;
    for (int i=0; i<N; i++)
    {
        nxt[i] = N;
        for (int j=i + 1; j<N; j++)
            if (query (i, i, i, j) == 0)
            {
                nxt[i] = j;
                break;
            }
    }
    int root = solve (0, N - 1, Left, Right);
    return root;
}
# Verdict Execution time Memory Grader output
1 Correct 47 ms 376 KB Output is correct
2 Correct 120 ms 440 KB Output is correct
3 Correct 27 ms 440 KB Output is correct
4 Correct 105 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 250 ms 532 KB too many queries
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 532 KB too many queries
2 Halted 0 ms 0 KB -