# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647798 | allin27x | 동굴 (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 <iostream>
#include <cave.h>
using namespace std;
int tryCombination(int S[]);
void answer(int S[], int D[]);
void solveSubtask1(int N){
int q[N] = {};
int ans = tryCombination(q);
int c = 0;
while (ans!=-1){
if (c>n) solveSubtask3(N);
q[ans] = 1;
ans = tryCombination(q);
c++;
}
int t[N];
for (int i=0; i<N; i++){
t[i] = i;
}
answer(q, t);
}
void solveSubtask2(int N){
int ans[N] = {};
int q[N] = {};
q[0] = 1;
ans[0] = tryCombination(q);
for (int i=1; i<N; i++){
q[i-1] = 0;
q[i] = 1;
ans[i] = tryCombination(q);
}
q[N-1] = 0;
answer(q, ans);
}
void solveSubtask3(int N){
int q[N] = {};
int ans[N] = {};
int s = tryCombination(q);
int t=-1;
while (s!=-1){
for (int i=0; i<N; i++){
if (q[i] != 1){
q[i] = 1;
t = tryCombination(q);
if (t==-1 or t>s){
ans[i] = s;
break;
}
q[i] = 0;
}
}
s = tryCombination(q);
}
q[0] = !q[0];
ans[0] = tryCombination(q);
for (int i=1; i<N; i++){
q[i-1] = !q[i-1];
q[i] = !q[i];
ans[i] = tryCombination(q);
}
q[N-1] = !q[N-1];
answer(q ,ans);
}
void exploreCave(int N){
solveSubtask3(N);
}