제출 #443599

#제출 시각아이디문제언어결과실행 시간메모리
443599Lam_lai_cuoc_doiCave (IOI13_cave)C++17
컴파일 에러
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 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) { 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, 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); }

컴파일 시 표준 에러 (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: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:44:24: error: request for member 'size' in 'a', which is of non-class type 'int [5005]'
   44 |         if (Guess(0, a.size(), 1) > i)
      |                        ^~~~
cave.cpp:46:32: error: request for member 'size' in 'a', which is of non-class type 'int [5005]'
   46 |             int tmp = Get(0, a.size(), 1, i);
      |                                ^~~~
cave.cpp:49:24: error: request for member 'back' in 'a', which is of non-class type 'int [5005]'
   49 |             a[tmp] = a.back();
      |                        ^~~~
cave.cpp:50:15: error: request for member 'pop_back' in 'a', which is of non-class type 'int [5005]'
   50 |             a.pop_back();
      |               ^~~~~~~~
cave.cpp:54:32: error: request for member 'size' in 'a', which is of non-class type 'int [5005]'
   54 |             int tmp = Get(0, a.size(), 0, i);
      |                                ^~~~
cave.cpp:57:24: error: request for member 'back' in 'a', which is of non-class type 'int [5005]'
   57 |             a[tmp] = a.back();
      |                        ^~~~
cave.cpp:58:15: error: request for member 'pop_back' in 'a', which is of non-class type 'int [5005]'
   58 |             a.pop_back();
      |               ^~~~~~~~