제출 #647805

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

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

void solveSubtask23(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;
                    s=t;
                    break;
                }
                q[i] = 0;
            }
        }
    }
    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) solveSubtask23(N);
        q[ans] = 1;
        ans = tryCombination(q);
        c++;
    }

    for (int i=0; i<N; i++){
        q[i] = !q[i];
        if (tryCombination(q) != i) solveSubtask23(N);
        q[i] = !q[i];
    }
    int t[N];
    for (int i=0; i<N; i++)
    {
        t[i] = i;
    }
    answer(q, t);
}



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...