Submission #284635

#TimeUsernameProblemLanguageResultExecution timeMemory
284635triplem5dsCave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include "cave.h" #include "bits/stdc++.h" using namespace std; void exploreCave(int N) { n = N; memset(ans, -1, sizeof ans); for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++)if(ans[j] == -1)S[j] = 0; else S[j] = ans[j]; int x = tryCombination(S); if(x == -1)x = N; bool f = (x <= i); ///the door is closed then it should be open by the other state ///find which switch is it int lo = 0, hi = N - 1 - i; while(lo < hi){ int md = lo + (hi - lo) / 2; int cnt = 0; for(int j = 0; j < N; j++){ if(ans[j] != -1)S[j] = ans[j]; else { S[j] = (f ^ (cnt > md)); cnt++; } } int x = tryCombination(S); if(x == -1)x = N; if(x > i) hi = md; else lo = md + 1; } int cnt = 0; for(int j = 0; j < n; j++){ if(ans[j] == -1){ if(cnt == lo){ ans[j]=f; W[j] = i; break; } cnt++; } } } answer(ans,W); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:5:3: error: 'n' was not declared in this scope
    5 |   n = N;
      |   ^
cave.cpp:6:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
    6 |   memset(ans, -1, sizeof ans);
      |          ^~~
      |          abs
cave.cpp:8:47: error: 'S' was not declared in this scope
    8 |     for(int j = 0; j < N; j++)if(ans[j] == -1)S[j] = 0;
      |                                               ^
cave.cpp:9:10: error: 'S' was not declared in this scope
    9 |     else S[j] = ans[j];
      |          ^
cave.cpp:10:28: error: 'S' was not declared in this scope
   10 |     int x = tryCombination(S);
      |                            ^
cave.cpp:37:11: error: 'W' was not declared in this scope
   37 |           W[j] = i;
      |           ^
cave.cpp:44:14: error: 'W' was not declared in this scope
   44 |   answer(ans,W);
      |              ^