Submission #81072

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
810722018-10-23 16:55:50arman_ferdousCave (IOI13_cave)C++17
100 / 100
372 ms548 KiB
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
void exploreCave(int N) {
int S[N], D[N];
memset(S,0,sizeof S);
memset(D,-1,sizeof D);
for(int i = 0; i < N; i++) {
int bad = tryCombination(S);
int stat = (bad == i);
int lo = 0, hi = N-1, idx;
while(lo <= hi) {
int mid = (lo + hi) >> 1;
for(int i = lo; i <= mid; i++) if(D[i] == -1) S[i] ^= 1;
int blok = tryCombination(S);
for(int i = lo; i <= mid; i++) if(D[i] == -1) S[i] ^= 1;
if(stat == 0) {
if(blok == i) idx = mid, hi = mid-1;
else lo = mid+1;
} else {
if(blok > i || blok == -1) idx = mid, hi = mid-1;
else lo = mid+1;
}
}
D[idx] = i;
S[idx] = stat;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:29:13: warning: 'idx' may be used uninitialized in this function [-Wmaybe-uninitialized]
      D[idx] = i;
      ~~~~~~~^~~
#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...