제출 #647800

#제출 시각아이디문제언어결과실행 시간메모리
647800allin27x동굴 (IOI13_cave)C++14
12 / 100
9 ms392 KiB
#include <iostream>
#include <cave.h>
using namespace std;

int tryCombination(int S[]);
void answer(int S[], int D[]);

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 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 exploreCave(int N){
    solveSubtask1(N);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...