Submission #680414

#TimeUsernameProblemLanguageResultExecution timeMemory
680414Nahian9696Cave (IOI13_cave)C++17
100 / 100
889 ms460 KiB
#include "cave.h"
#include <bits/stdc++.h>

using namespace std;

#define f0(i, n) for (int i = 0; i < (n); ++i)
#define f1(i, n) for (int i = 1; i <= (n); ++i)

void exploreCave(int N) {
    /* ... */
    int S[N], D[N], dr;
    bool DK[N], on;
    memset(DK, 0, sizeof(DK));
    memset(S, -1, sizeof(S));
    memset(D, -1, sizeof(D));

    f0(door, N) {
        f0(i, N) {
            if(DK[i]) continue;
            S[i] = 1;
        }
        dr = tryCombination(S);
        if(dr > door || dr == -1) {
            on = 1;
        } else {
            on = 0;
        }
        // cout << on << endl;
        int key = 0;
        f0(bit, 13) {
            f0(i, N) {
                if(DK[i]) continue;
                if(i & (1 << bit)) {
                    S[i] = on;
                } else {
                    S[i] = (1-on);
                }
            }
            // f0(i, N) cout << S[i] << " "; cout << endl;
            dr = tryCombination(S);
            if(dr > door || dr == -1) {
                key |= (1 << bit);
                // cout << bit << " " << dr << endl;
            }
        }
        // cout << key << " " << door << endl;
        D[key] = door;
        DK[key] = true;
        S[key] = on;
    }


    answer(S, D);
}
#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...