# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154348 | songc | 동굴 (IOI13_cave) | C++14 | 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.
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
int N;
int S[5050];
int ans[5050];
void exploreCave(int n) {
N = n;
memset(ans, -1, sizeof ans);
for (int i=0; i<N; i++){
bool st = (i == tryCombination(S));
int l = 0, r=N-1;
while (l < r){
int mid = (l+r)/2;
for (int i=l; i<=mid; i++) if (ans[i] == -1) S[i] = 1;
bool ret = (i == tryCombination());
if (st == ret) l = mid+1;
else r = mid;
for (int i=l; i<=mid; i++) if (ans[i] == -1) S[i] = 0;
}
ans[i] = l;
if (st) S[l] = 1;
}
answer(S, ans);
}