Submission #104678

#TimeUsernameProblemLanguageResultExecution timeMemory
104678ErkhemkhuuCave (IOI13_cave)C++17
100 / 100
534 ms560 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; #define n 5005 bool vis[n + 5]; int ind[n + 5], switches[n + 5]; void run(int l, int r, bool flag) { int i; for(i = l; i <= r; i++) if(!vis[i]) switches[i] = flag; return; } void exploreCave(int N) { memset(vis, false, sizeof(vis)); memset(ind, 0, sizeof(ind)); int i, l, r, mid; bool flag; for(i = 0; i < N; i++) { run(0, N - 1, false); flag = tryCombination(switches) == i; l = 0; r = N ; while(l != r) { int mid = (l + r) / 2; run(l, mid, flag); run(mid + 1, r, flag ^ 1); if(tryCombination(switches) == i) l = mid + 1; else r = mid; } vis[l] = true; switches[l] = flag; ind[l] = i; } answer(switches, ind); return; }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:16:15: warning: unused variable 'mid' [-Wunused-variable]
  int i, l, r, mid;
               ^~~
#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...