This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |