Submission #1344804

#TimeUsernameProblemLanguageResultExecution timeMemory
1344804sdanCave (IOI13_cave)C++20
0 / 100
31 ms500 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second

void exploreCave(int n) {
    int s[n], d[n]; for(int i = 0; i < n; ++i) s[i] = 0, d[i] = -1;
    int k = -1;

    for(int i = 0; i < n; ++i) {
        k = tryCombination(s);
        if(k != i) for(int i = 0; i < n; ++i)
            if(d[i] == -1) s[i] = s[i] ^ 1;

        int l = 0, r = n, mod;
        while(l + 1 < r) {
            int m = (l + r) / 2;

            for(int i = l; i < m; ++i)
                if(d[i] == -1) s[i] = s[i] ^ 1;

            k = tryCombination(s);
            if(k == i) l = m, mod = 0;
            else {
                for(int i = l; i < m; ++i)
                    if(d[i] == -1) s[i] = s[i] ^ 1;
                r = m, mod = 1;
            }
        }

        d[l] = i;
        if(mod) s[l] = s[l] ^ 1;
    }

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