Submission #945794

# Submission time Handle Problem Language Result Execution time Memory
945794 2024-03-14T07:48:18 Z vjudge1 Cave (IOI13_cave) C++17
0 / 100
17 ms 348 KB
#include "cave.h"

void exploreCave(int N)
{
    /* ... */
    int cur[N];
    int pos[N];

    int req[N];
    for (int i = 0; i < N; ++i)
    {

        int L = 0, R = N;

        int val = tryCombination(req);
        int V;
        if (val > i or val == -1)
            V = 0;
        else
            V = 1;

        while (R - L > 1)
        {
            int M = (L + R) >> 1;
            for (int j = L; j < M; ++j)
                req[j] = V;
            for (int j = M; j < R; ++j)
                req[j] = 1 - V;
            int val = tryCombination(req);
            if (val > i or val == -1)
                R = M;
            else
                L = M;
        }
        cur[i] = V;
        pos[i] = L;
    }

    answer(cur, pos);
}

// ///////////////////////////////////////

// #include "cave.h"
// #include <assert.h>
// #include <stdio.h>
// #include <stdlib.h>

// #define MAX_N 5000
// #define MAX_CALLS 70000

// static int N;
// static int realS[MAX_N];
// static int realD[MAX_N];
// static int inv[MAX_N];
// static int num_calls;

// void answer(int S[], int D[])
// {
//     int i;
//     for (i = 0; i < N; ++i)
//         if (S[i] != realS[i] || D[i] != realD[i])
//         {
//             printf("INCORRECT\nWrong answer:");
//             if (S[i] != realS[i])
//                 printf("S[%d] != realS[%d]", i, i);
//             else
//                 printf("D[%d] != realD[%d]", i, i);
//             exit(0);
//         }

//     printf("CORRECT\n");
//     exit(0);
// }

// int tryCombination(int S[])
// {
//     int i;

//     if (num_calls >= MAX_CALLS)
//     {
//         printf("INCORRECT\nToo many calls to tryCombination().\n");
//         exit(0);
//     }
//     ++num_calls;

//     for (i = 0; i < N; ++i)
//         if (S[inv[i]] != realS[inv[i]])
//             return i;
//     return -1;
// }

// int init()
// {
//     int i;

//     assert(scanf("%d", &N) == 1);

//     for (i = 0; i < N; ++i)
//     {
//         assert(scanf("%d", &realS[i]) == 1);
//     }
//     for (i = 0; i < N; ++i)
//     {
//         assert(scanf("%d", &realD[i]) == 1);
//         inv[realD[i]] = i;
//     }

//     num_calls = 0;
//     return N;
// }

// int main()
// {
//     int N;
//     N = init();
//     exploreCave(N);
//     printf("INCORRECT\nYour solution did not call answer().\n");
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -