Submission #585095

#TimeUsernameProblemLanguageResultExecution timeMemory
585095EinsiteinCave (IOI13_cave)C++98
100 / 100
233 ms460 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; namespace { } // namespace void exploreCave(int N) { vector<int> s(N); vector<int> d(N); vector<int> guess(N, 0); vector<bool> done(N, 0); auto toggle = [&](int l, int r) -> void { for (int i = l; i < r; i++) { if (!done[i]) guess[i] ^= 1; } }; for (int i = 0; i < N; i++) { int lo = 0, hi = N; bool last = (tryCombination(guess.data()) + N + 1) % (N + 1) > i; while (hi - lo > 1) { int mid = (lo + hi) / 2; toggle(lo, mid); if (last != (tryCombination(guess.data()) + N + 1) % (N + 1) > i) { last = !last; hi = mid; } else lo = mid; } s[lo] = last ^ guess[lo] ^ 1; d[lo] = i; done[lo] = 1; guess[lo] = s[lo]; } answer(s.data(), d.data()); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:38:74: warning: suggest parentheses around comparison in operand of '!=' [-Wparentheses]
   38 |             if (last != (tryCombination(guess.data()) + N + 1) % (N + 1) > 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...