Submission #1092188

#TimeUsernameProblemLanguageResultExecution timeMemory
1092188pubin06Cave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; const int MXn = 5005; //int n = 4, S[] = {1, 1, 1, 0}, D[] = {3, 1, 0, 2}; //int tryCombination(int a[]) { // int ans = n; // cout << "[ "; // for (int i = 0; i < n; i++) { // cout << a[i] << ' '; // if (a[i] != S[i]) { // ans = min(ans, D[i]); // } // } // cout << "]: " << ((ans == n) ? -1 : ans) << '\n'; // return (ans == n) ? -1 : ans; //} int ask(int a[]) { int res = tryCombination(a); if (res < 0) res = n; return res; } int ans[MXn], arr[MXn], pos[MXn]; bool ok[MXn]; void exploreCave(int N) { n = N; memset(ans, 0, sizeof ans); for (int i = 0; i < N; i++) { int t = tryCombination(ans) == i ? 0 : 1; int l = 0, r = N - 1, mid, res; while (l <= r) { mid = (l + r) >> 1; for (int i = 0; i < N; i++) { if (ok[i]) arr[i] = ans[i]; else if (i <= mid) arr[i] = 1; } int tmp = ask(arr); if (t) { if (tmp == i) { res = mid; r = mid - 1; } else l = mid + 1; } else { if (tmp > i) { res = mid; r = mid - 1; } else l = mid + 1; } for (int i = 0; i < N; i++) { if (ok[i]) arr[i] = ans[i]; else if (i <= mid) arr[i] = 0; } } ok[res] = true; ans[res] = t ^ 1; pos[res] = i; } // for (int i = 0; i < N; i++) cout << ans[i] << ' '; // cout << '\n'; // for (int i = 0; i < N; i++) cout << pos[i] << ' '; answer(ans, pos); }

Compilation message (stderr)

cave.cpp: In function 'int ask(int*)':
cave.cpp:23:24: error: 'n' was not declared in this scope
   23 |     if (res < 0) res = n;
      |                        ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:29:5: error: 'n' was not declared in this scope
   29 |     n = N;
      |     ^