# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
993139 | Rifal | Cave (IOI13_cave) | C++14 | 1511 ms | 600 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] = {};
int x = tryCombination(now);
int cnt = 1;
for(int i = 0; i < N; i++) {
int l = 0, r = N-1;
for(int j = 0; j < N; j++) {
if(S[j] == -1) now[j] = -1;
else now[j] = S[j];
}
// cout << x << ' ' << i << 'a' << endl;
if(i == x) {
while(l < r) {
int mid = (l+r)/2;
vector<int> v;
for(int j = 0; j <= N; j++) {
if(now[j] == -1 && j >= l && j <= mid) {
v.push_back(j);
now[j] = 1;
}
else if(now[j] == -1) {
v.push_back(j);
now[j] = 0;
}
}
cnt++;
// for(int j = 0; j < N; j++) cout << now[j] << ' ';
int y = tryCombination(now);
// cout << y << 'o' << endl;
x = tryCombination(now);
// cout << endl;
// cout << l << ' ' << mid << ' ' << r << ' ' << x << 'b' << endl;
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 = 0; j <= N; j++) {
if(now[j] == -1 && j >= l && j <= mid) {
v.push_back(j);
now[j] = 1;
}
else if(now[j] == -1) {
v.push_back(j);
now[j] = 0;
}
}
cnt++;
x = tryCombination(now);
// cout << l << ' ' << mid << ' ' << r << ' ' << x << 'c' << endl;
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... |