Submission #945441

# Submission time Handle Problem Language Result Execution time Memory
945441 2024-03-13T19:27:45 Z codefox Cave (IOI13_cave) C++14
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
#include "cave.h"

using namespace std;

void exploreCave(int N) {
    int b[N];
    int ans[N];

    for (int i = 0; i < N; i++)
    {
        b[i] = 0;
        ans[i] = -1;
    }
    int l = 1;
    int n = N;
    while (N)
    {
        N/=2;
        l++;
    }

    int f = tryCombination(b);
    for (int i = 0; i < N; i++)
    {
        if (f !=i)
        {
            for (int j = 0; j < N; j++)
            {
                if (ans[j]==-1) b[j] = 1-b[j];
            }            
        }
        int curr = 0;
        for (int j = l; j >= 0; j--)
        {
            for (int k = curr; k < curr + (1<<j) && k <N; k++)
            {
                if (ans[k]==-1) b[k] = 1-b[k];
            }
            int h = tryCombination(b);
            for (int k = curr; k < curr + (1<<j) && k <N; k++)
            {
                if (ans[k]==-1) b[k] = 1-b[k];
            }
            if (h != i) continue;
            curr += 1<<j;
        }
        b[curr] = 1-b[curr];
        ans[curr] = i;
        f = tryCombination(b);
    }
    answer(b, ans);
}

Compilation message

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:16:9: warning: unused variable 'n' [-Wunused-variable]
   16 |     int n = N;
      |         ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Answer is wrong
2 Halted 0 ms 0 KB -