Submission #61164

# Submission time Handle Problem Language Result Execution time Memory
61164 2018-07-25T09:42:20 Z SpaimaCarpatilor popa (BOI18_popa) C++17
0 / 100
19 ms 512 KB
#include<bits/stdc++.h>
#include "popa.h"

using namespace std;

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 ras = (l + r) / 2;
    if (query (l, ras, l, r))
    {
        for (int i=l; i<ras; i++)
            if (query (l, i, l, r))
            {
                ras = i;
                break;
            }
    }
    else
    {
        for (int i=r - 1; i>ras; i--)
            if (query (ras, r, l, r))
            {
                ras = i;
                break;
            }
    }
    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;
    int root = solve (0, N - 1, Left, Right);
    return root;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 376 KB not a valid solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 512 KB not a valid solution
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 512 KB not a valid solution
2 Halted 0 ms 0 KB -