Submission #256545

#TimeUsernameProblemLanguageResultExecution timeMemory
256545Harry464Cave (IOI13_cave)C++14
0 / 100
1134 ms504 KiB
#include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <cstring> #include "cave.h" typedef int ll; using namespace std; void exploreCave(int n) { ll sw[n]; ll odg[n]; for (int i = 0; i < n; i++) sw[i] = 0, odg[i] = -1; for (int j = 0; j < n; j++){ vector <ll> free; for (int i = 0; i < n; i++) if (odg[i] == -1) free.push_back(i), sw[i] = 1; ll ask = tryCombination(sw); ll trig; if (ask == j) trig = 0; else trig = 1; ll l = 0, r = free.size() - 1; while (l < r){ ll mid = (l+r)/2; for (int i = l; i <= mid; i++) sw[free[i]] = trig; for (int i = 0; i < l; i++) sw[free[i]] = (trig+1)%2; for (int i = mid + 1; i < free.size(); i++) sw[free[i]] = (trig+1)%2; ask = tryCombination(sw); if (ask == j) l = mid + 1; else r = mid; } sw[l] = trig; odg[l] = j; } answer(sw,odg); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:36:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = mid + 1; i < free.size(); 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...