Submission #61166

# Submission time Handle Problem Language Result Execution time Memory
61166 2018-07-25T09:44:16 Z SpaimaCarpatilor popa (BOI18_popa) C++17
61 / 100
166 ms 664 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; i>ras; i--)
            if (query (i, 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 Correct 12 ms 248 KB Output is correct
2 Correct 16 ms 436 KB Output is correct
3 Correct 13 ms 436 KB Output is correct
4 Correct 20 ms 552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 624 KB Output is correct
2 Correct 137 ms 624 KB Output is correct
3 Correct 114 ms 664 KB Output is correct
4 Correct 164 ms 664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 664 KB too many queries
2 Halted 0 ms 0 KB -