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;
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int,int>
#define st first
#define nd second
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define LL node * 2
#define RR node * 2 + 1
#define mid (l + r) / 2
#define ll long long
#define MAXN 200005
#define LOGN 12
void exploreCave(int N) {
int done[N], curr[N];
for (int i = 0; i < N; i++)
done[i] = -1, curr[i] = 0;
auto question = [&](int x, int val){
int tmpx = x;
int lst = -1;
for (int i = 0; i < N; i++){
if (x > 0 && done[i] == -1) curr[i] = val, x--, lst = i;
else if (done[i] == -1) curr[i] = 1 - val;
}
int res = tryCombination(curr);
return res;
};
for (int i = 0; i < N; i++){
int val = 0;
int gh = question(0, 1);
if (gh >= i + 1 || gh == -1){
val = 1;
}
int pos = 0;
for (int j = LOGN; j >= 0; j--){
int tmp = pos + (1<<j);
int t = question(tmp, val);
// cout<<i<<sp<<val<<sp<<tmp<<sp<<t<<endl;
if (t >= i + 1 || t == -1) pos = tmp;
}
pos++;
int lst = 0;
for (int i = 0; i < N; i++){
if (done[i] == -1 && pos > 0) lst = i, pos--;
}
done[lst] = i;
curr[lst] = 1 - val;
}
answer(curr, done);
}
Compilation message (stderr)
cave.cpp: In lambda function:
cave.cpp:29:17: warning: unused variable 'tmpx' [-Wunused-variable]
29 | int tmpx = x;
| ^~~~
cave.cpp:30:17: warning: variable 'lst' set but not used [-Wunused-but-set-variable]
30 | int lst = -1;
| ^~~
# | 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... |