Submission #443600

#TimeUsernameProblemLanguageResultExecution timeMemory
443600Lam_lai_cuoc_doiCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#define task ""

#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;

#include "cave.h"

constexpr int N = 5e3 + 5;
int a[N], s[N], d[N];
int m;

int Guess(int l, int r, int v)
{
    for (int i = l; i <= r; ++i)
        s[i] = v;
    int v = tryCombination(s);
    return (v == -1 ? n : v);
}

int Get(int l, int r, const int &v, const int &i)
{
    while (l != r)
    {
        if (Guess(l, (l + r) / 2, != v) == i)
            r = (l + r) / 2;
        else
            l = (l + r) / 2 + 1;
    }
    return l;
}

void exploreCave(int n)
{
    m = n - 1;
    for (int i = 0; i < n; ++i)
        a[i] = i;

    for (int i = 0; i < n; ++i)
    {
        if (Guess(0, a.size(), 1) > i)
        {
            int tmp = Get(0, m, 1, i);
            s[a[tmp]] = 1;
            d[a[tmp]] = i;
            a[tmp] = a[m];
            --m;
        }
        else
        {
            int tmp = Get(0, a.size(), 0, i);
            s[a[tmp]] = 0;
            d[a[tmp]] = i;
            a[tmp] = a[m];
            --m;
        }
    }
    answer(s, d);
}

Compilation message (stderr)

cave.cpp: In function 'int Guess(int, int, int)':
cave.cpp:22:9: error: declaration of 'int v' shadows a parameter
   22 |     int v = tryCombination(s);
      |         ^
cave.cpp:18:29: note: 'int v' previously declared here
   18 | int Guess(int l, int r, int v)
      |                         ~~~~^
cave.cpp:23:23: error: 'n' was not declared in this scope
   23 |     return (v == -1 ? n : v);
      |                       ^
cave.cpp: In function 'int Get(int, int, const int&, const int&)':
cave.cpp:30:35: error: expected primary-expression before '!=' token
   30 |         if (Guess(l, (l + r) / 2, != v) == i)
      |                                   ^~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:46:24: error: request for member 'size' in 'a', which is of non-class type 'int [5005]'
   46 |         if (Guess(0, a.size(), 1) > i)
      |                        ^~~~
cave.cpp:56:32: error: request for member 'size' in 'a', which is of non-class type 'int [5005]'
   56 |             int tmp = Get(0, a.size(), 0, i);
      |                                ^~~~