Submission #941405

# Submission time Handle Problem Language Result Execution time Memory
941405 2024-03-08T18:10:07 Z tset Cave (IOI13_cave) C++14
0 / 100
425 ms 560 KB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;

vector<int> posLevierOpt, corresp;

bool test(int deb, int fin, int porteAOuvrir, int N)
{
    int tabTest[N];
    for(int i=0; i<N; i++)
    {
        if(posLevierOpt[i]!= -1)
            tabTest[i] = posLevierOpt[i];
        else if(i>= deb && i <= fin)
            tabTest[i] = 1;
        else
            tabTest[i] = 0;
    }
    int lastDoorOpen = tryCombination(tabTest);
    if(lastDoorOpen == -1 || lastDoorOpen >= porteAOuvrir)
        return true;
    return false;
}

void exploreCave(int N)
{
    posLevierOpt.assign(N, -1);
    corresp.assign(N, -1);
    for(int iDoor = 0; iDoor< N; iDoor++)
    {
        bool stateDoorInit = test(0, N-1, iDoor, N);
        int deb = 0;
        int fin = N-1;
        while (deb < fin)
        {
            int mid = (deb + fin)/2;
            if(test(deb, mid, iDoor, N)!=stateDoorInit)
                fin = mid;
            else
                deb = mid +1;
        }
        if(stateDoorInit)
            posLevierOpt[deb] = 0;
        posLevierOpt[deb] = 1;
        corresp[deb] = iDoor;
    }
    int answer[2*N];
    for(int i=0; i< N;i++)
        answer[i] = posLevierOpt[i];
    for(int i=0; i< N;i++)
        answer[N+i] = corresp[i];
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:47:9: warning: variable 'answer' set but not used [-Wunused-but-set-variable]
   47 |     int answer[2*N];
      |         ^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 250 ms 348 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 425 ms 560 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 250 ms 348 KB answer() 함수를 반드시 호출해야 합니다.
2 Halted 0 ms 0 KB -