Submission #738656

#TimeUsernameProblemLanguageResultExecution timeMemory
738656BidoTeimaCave (IOI13_cave)C++17
Compilation error
0 ms0 KiB
#include "cave.h" #include <bits/stdc++.h> int n; int pos[5000]; int door[5000]; int dnc(int l, int r, bool b, int target){ if(l == r) return l; int mid = (l + r) >> 1; // first check if it's in [l, mid] int s[n]; for(int i = 0; i < n; i++){ if(pos[i] != -1){ s[i] = pos[i]; } else if(l <= i && i <= mid){ s[i] = b; } else{ s[i] = !b; } } int res = tryCombination(s); if(res <= target && res != -1){ return dnc(mid + 1, r, b, target); } return dnc(l, mid, b, target); } void exploreCave(int N) { n = N; memset(pos, -1, sizeof(pos)); for(int i = 0; i < n; i++){ int s[n]; for(int j = 0; j < n; j++){ if(pos[j] != -1)s[j] = pos[j]; else s[j] = 0; } int res = tryCombination(s); bool b = 0; if(res <= i && res != -1){ b = 1; } int s = dnc(0, n-1, b, i); pos[s] = b; door[s] = i; } answer(pos, door); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:43:13: error: conflicting declaration 'int s'
   43 |         int s = dnc(0, n-1, b, i);
      |             ^
cave.cpp:33:13: note: previous declaration as 'int s [n]'
   33 |         int s[n];
      |             ^
cave.cpp:44:12: error: invalid types 'int [5000][int [n]]' for array subscript
   44 |         pos[s] = b;
      |            ^
cave.cpp:45:13: error: invalid types 'int [5000][int [n]]' for array subscript
   45 |         door[s] = i;
      |             ^