Submission #1326012

#TimeUsernameProblemLanguageResultExecution timeMemory
1326012hyyhCave (IOI13_cave)C++20
100 / 100
540 ms504 KiB
#include "cave.h"

#include <bitset>
#include <vector>
#include <iostream>

using namespace std;

#define endl '\n'

void exploreCave(int N) {
    int button[N];
    fill(button,button+N,-1);
    int combination[N];
    int test[N];
    for(int i{1};i <= N;i++){
        int l = 0;
        int r = N-1;
        fill(test,test+N,0);
        for(int i{0};i < N;i++) if(button[i] != -1) test[i] = combination[i];
        //for(auto k:test) cout << k;
        //cout << endl;
        int val = tryCombination(test);
        //cout << val << endl << endl;
        int optype = (val >= i || val == -1);
        int md;
        int ans = 0;

        while(l < r){
            md = l+(r-l)/2;
            fill(test,test+N,optype);
            //cout << l << " " << md << " " << r << endl;
            for(int i{0};i < N;i++){
                if(button[i] != -1) test[i] = combination[i];
                else if(i >= l && i <= md) test[i] = 1-optype;
                //cout << button[i];
            }
            // cout << endl;
            // for(auto k:test) cout << k;
            // cout << endl;
            int get = tryCombination(test);
            //cout << get << endl << endl;
            if(get >= i || get == -1){
                r = md;
            }
            else l = md+1;
        }
        md = (l+r)/2;
        button[md] = i - 1;
        combination[md] = 1-optype;
    }
    answer(combination,button);
}
#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...