# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
992898 | Rifal | Cave (IOI13_cave) | C++14 | 3 ms | 572 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 "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
int now[N] = {};
int S[N];
for(int i = 0; i < N; i++) S[i] = -1;
int D[N] = {};
for(int i = 0; i < N; i++) {
for(int j = 0; j < N; j++) {
if(S[j] == -1) now[j] = 0;
else now[j] = S[j];
}
int l = 0, r = N-1;
int x = tryCombination(now);
for(int j = 0; j < N; j++) {
if(S[j] == -1) now[j] = -1;
else now[j] = S[j];
}
if(i == x) {
while(l <= r) {
int mid = (l+r)/2;
vector<int> v;
for(int j = l; j <= mid; j++) {
if(now[j] == -1) {
v.push_back(j);
now[j] = 1;
}
}
x = tryCombination(now);
if(x == i) {
l = mid+1;
}
else {
r = mid;
}
for(int j = 0; j < v.size(); j++) {
now[v[j]] = -1;
}
}
S[l] = 0;
D[i] = l;
}
else {
while(l <= r) {
int mid = (l+r)/2;
vector<int> v;
for(int j = l; j <= mid; j++) {
if(now[j] == -1) {
v.push_back(j);
now[j] = 1;
}
}
x = tryCombination(now);
if(x != i) {
l = mid+1;
}
else {
r = mid;
}
for(int j = 0; j < v.size(); j++) {
now[v[j]] = -1;
}
}
S[l] = 1;
D[i] = l;
}
}
answer(S,D);
}
Compilation message (stderr)
# | 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... |