Submission #672742

#TimeUsernameProblemLanguageResultExecution timeMemory
672742Hacv16Cave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "cave.h" using namespace std; typedef long long ll; const int MAX = 2e6 + 15; const int INF = 0x3f3f3f3f; int S[MAX], D[MAX]; bool mark[MAX]; bool f(int x, int j, int c){ for(int i = 0; i < x; i++) if(!mark[i]) S[i] = c; for(int i = x; i < n; i++) if(!mark[i]) S[i] = !c; int query = tryCombination(S); return (query != j); } void exploreCave(int n){ for(int door = 0; door < n; door++){ for(int i = 0; i < n; i++) if(!mark[i]) S[i] = 0; int color = (tryCombination(S) == door), pos = -1; int l = 0, r = n, pos = -1; while(l <= r){ int m = (l + r) >> 1; if(f(m, door, color)) r = m - 1, pos = m; else l = m + 1; } assert(pos != -1); mark[pos] = true; D[pos] = door; S[pos] = color; } answer(S, D); }

Compilation message (stderr)

cave.cpp: In function 'bool f(int, int, int)':
cave.cpp:15:21: error: 'n' was not declared in this scope
   15 |  for(int i = x; i < n; i++) if(!mark[i]) S[i] = !c;
      |                     ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:28:21: error: redeclaration of 'int pos'
   28 |   int l = 0, r = n, pos = -1;
      |                     ^~~
cave.cpp:26:44: note: 'int pos' previously declared here
   26 |   int color = (tryCombination(S) == door), pos = -1;
      |                                            ^~~