Submission #443598

#TimeUsernameProblemLanguageResultExecution timeMemory
443598Lam_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 = 2e5 + 5; vector<int> a, s, d; 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) { s.resize(n, 0); d.resize(n, 0); for (int i = 0; i < n; ++i) a.emplace_back(i); for (int i = 0; i < n; ++i) { if (Guess(0, a.size(), 1) > i) { int tmp = Get(0, a.size(), 1, i); s[a[tmp]] = 1; d[a[tmp]] = i; a[tmp] = a.back(); a.pop_back(); } else { int tmp = Get(0, a.size(), 0, i); s[a[tmp]] = 0; d[a[tmp]] = i; a[tmp] = a.back(); a.pop_back(); } } answer(s, d); }

Compilation message (stderr)

cave.cpp: In function 'int Guess(int, int, int)':
cave.cpp:21:9: error: declaration of 'int v' shadows a parameter
   21 |     int v = tryCombination(s);
      |         ^
cave.cpp:17:29: note: 'int v' previously declared here
   17 | int Guess(int l, int r, int v)
      |                         ~~~~^
cave.cpp:21:28: error: cannot convert 'std::vector<int>' to 'int*'
   21 |     int v = tryCombination(s);
      |                            ^
      |                            |
      |                            std::vector<int>
In file included from cave.cpp:12:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:22:23: error: 'n' was not declared in this scope
   22 |     return (v == -1 ? n : v);
      |                       ^
cave.cpp: In function 'int Get(int, int, const int&, const int&)':
cave.cpp:29:35: error: expected primary-expression before '!=' token
   29 |         if (Guess(l, (l + r) / 2, != v) == i)
      |                                   ^~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:64:12: error: cannot convert 'std::vector<int>' to 'int*'
   64 |     answer(s, d);
      |            ^
      |            |
      |            std::vector<int>
In file included from cave.cpp:12:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~