Submission #1085020

#TimeUsernameProblemLanguageResultExecution timeMemory
1085020SunbaeCave (IOI13_cave)C++17
0 / 100
2 ms520 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; const int N = 5005; int n, s[N], d[N], a[N]; bool vis[N]; void exploreCave(int nn){ n = nn; fill(s, s+n, 0); fill(vis, vis+n, false); for(int i = 0; i<n; ++i){ // i is door to open for(int j = 0; j<n; ++j) a[i] = (vis[j])? s[j] : 0; int door = tryCombination(a); if(door == -1) door = n; int col = (door > i) ? 0 : 1; int low = 0, high = n-1, idx; for(int j = 0; j<n; ++j) a[i] = (vis[j])? s[j] : 0; while(low <= high){ int mid = low + ((high-low)>>1); for(int j = low; j<=high; ++j){ if(vis[j]) continue; if(j <= mid) a[j] = col; else a[j] = col^1; } int door = tryCombination(a); if(door == -1) door = n; if(door > i){ high = mid; idx = mid; }else{ low = mid+1; } } s[idx] = col; d[idx] = i; vis[idx] = true; } answer(s, d); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:33:12: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
   33 |   vis[idx] = true;
      |   ~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...