Submission #483049

# Submission time Handle Problem Language Result Execution time Memory
483049 2021-10-27T15:08:32 Z Lam_lai_cuoc_doi popa (BOI18_popa) C++17
Compilation error
0 ms 0 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);
    shuffle(s.begin(), s.end(), rand);

    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[0];
    right = &r[0];
    memset(l, -1, sizeof l);
    memset(r, -1, sizeof r);

    return solve(1, n);
}

void Read()
{
}

void Solve()
{
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen("xor.INP", "r"))
    {
        freopen("xor.inp", "r", stdin);
        freopen("xor.out", "w", stdout);
    }
    int t(1);
    if (typetest)
        cin >> t;
    for (int _ = 1; _ <= t; ++_)
    {
        // cout << "Case #" << _ << ": ";
        Read();
        Solve();
    }
    // cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}

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;
      |                  ^
popa.cpp: In function 'int solve(int, int*, int*)':
popa.cpp:51:10: error: assignment of function 'std::ios_base& std::left(std::ios_base&)'
   51 |     left = &l[0];
      |     ~~~~~^~~~~~~
popa.cpp:52:11: error: assignment of function 'std::ios_base& std::right(std::ios_base&)'
   52 |     right = &r[0];
      |     ~~~~~~^~~~~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from popa.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _UGenerator = int (&)() noexcept]':
popa.cpp:30:37:   required from here
/usr/include/c++/10/bits/stl_algo.h:3769:2: error: 'std::remove_reference<int (&)() noexcept>::type' {aka 'int() noexcept'} is not a class, struct, or union type
 3769 |  __uc_type;
      |  ^~~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<int (&)() noexcept>::type' {aka 'int() noexcept'} is not a class, struct, or union type
 3797 |    const pair<__uc_type, __uc_type> __pospos =
      |                                     ^~~~~~~~
/usr/include/c++/10/bits/stl_algo.h:3797:37: error: 'std::remove_reference<int (&)() noexcept>::type' {aka 'int() noexcept'} is not a class, struct, or union type
popa.cpp: In function 'int32_t main()':
popa.cpp:74:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |         freopen("xor.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
popa.cpp:75:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   75 |         freopen("xor.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~