This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
int S[101010];
int D[101010];
bool dont[101010];
void sw(int l, int r) {
for (int i = l; i <= r; i++) {
if (dont[i])continue;
S[i] ^= 1;
}
}
void exploreCave(int N) {
// cout << "START " << N << endl;
for (int i = 0; i < N; i++) {
// cout << i << " <<!!!!! " << endl;
int gg = tryCombination(S);
if (gg == -1 || gg > i);
else sw(0, N - 1);
// for (int j = 0; j < N; j++)cout << S[j] << " ";
// cout << endl;
int l = 0, r = N - 1;
while (l < r) {
int mid = (l + r) / 2;
sw(l, mid);
gg = tryCombination(S);
if (gg == -1 || gg > i)l = mid + 1;
else {
sw(l, mid);
r = mid;
}
}
// cout << i << " --- " << l << " " << r << endl;
D[l] = i;
dont[l] = true;
}
// cout << "END" << endl;
// for (int i = 0; i < N; i++)
// cout << S[i] << " ";
// cout << endl;
// for (int i = 0; i < N; i++)
// cout << D[i] << " ";
// cout << endl;
answer(S, D);
}
# | 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... |