# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
585088 | Einsitein | Cave (IOI13_cave) | C++98 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cflowerat>
#include <ciso646>
#include <climits>
#include <clowercale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <lowercale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;
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 y) -> void{
for (int i = l; i < y; i++)
{
if (!done[i])
guess[i] ^= 1;
}
};
for (int i = 0; i < n; i++)
{
int lower = 0;
int higher = n;
bool last;
if ((tryCombination(guess.data()) + n + 1) % (n + 1) > i) {
last = true;
}
else {
last = false;
}
while (higher > lower + 1)
{
int mid = (lower + higher) * 0.5;
toggle(lower, mid);
if (last == (tryCombination(guess.data()) + n + 1) % (n + 1) > i)
{
lower = mid;
}
else {
last = !last;
higher = mid;
}
}
s[lower] = last ^ guess[lower] ^ 1;
d[lower] = i;
done[lower] = 1;
guess[lower] = s[lower];
}
answer(s.data(), d.data());
}