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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
void exploreCave(int N) {
vector<int> doorIds(N);
vector<int> rightPos(N, -1);
for (int i = 0; i < N; i++) {
int comb[N];
for (int j = 0; j < N; j++) {
comb[j] = rightPos[j];
if(comb[j] == -1) comb[j] = 0;
}
bool base = !(tryCombination(comb) > i);
int l = 0, r = N - 1, mid;
while(l < r){
mid = (l + r) / 2;
for (int j = 0; j < N; j++) {
comb[j] = rightPos[j];
if(comb[j] == -1){
if(j <= mid) comb[j] = base;
else comb[j] = base ^ 1;
}
}
int x = tryCombination(comb);
if(x > i || x == -1) r = mid;
else l = mid + 1;
}
doorIds[i] = l;
rightPos[l] = base;
}
int ansId[N], ansR[N];
for (int i = 0; i < N; i++) {
ansId[doorIds[i]] = i;
ansR[i] = rightPos[i];
}
answer(ansR, ansId);
}
# | 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... |