답안 #483057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
483057 2021-10-27T15:15:15 Z Lam_lai_cuoc_doi popa (BOI18_popa) C++17
0 / 100
38 ms 312 KB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;

template <class T>
void read(T &x)
{
    x = 0;
    register int c;
    while ((c = getchar()) && (c > '9' || c < '0'))
        ;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
}

constexpr bool typetest = 0;
constexpr int N = 1e3 + 5;
constexpr ll Inf = 1e17;
int l[N], r[N];

int solve(int left, int right)
{
    vector<int> s;
    for (int i = left; i <= right; ++i)
        s.emplace_back(i);
    random_shuffle(s.begin(), s.end());

    int root = -1;

    for (auto i : s)
        if (query(i, i, left, right))
        {
            root = i;
            break;
        }

    if (root > left)
        l[root] = solve(left, root - 1);
    if (root < right)
        r[root] = solve(root + 1, right);

    return root;
}

int solve(int n, int *Left, int *Right)
{
    Left = l;
    Right = r;
    memset(l, -1, sizeof l);
    memset(r, -1, sizeof r);

    return solve(0, n - 1);
}

void Read()
{
}

void Solve()
{
}

Compilation message

popa.cpp: In function 'void read(T&)':
popa.cpp:13:18: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   13 |     register int c;
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 312 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 38 ms 304 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 20 ms 304 KB too many queries
2 Halted 0 ms 0 KB -