Submission #1344835

#TimeUsernameProblemLanguageResultExecution timeMemory
1344835sdanCave (IOI13_cave)C++20
100 / 100
106 ms504 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 j = 0; j < n; ++j)
            if(d[j] == -1) s[j] = s[j] ^ 1;

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

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

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

        d[l] = i;
        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...