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 <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#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 <locale>
#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>
#include"cave.h"
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 r) -> void
{
for (int i = l; i < r; i++)
{
if (!done[i])
guess[i] ^= 1;
}
};
for (int i = 0; i < N; i++)
{
int lower = 0, 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());
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |