Submission #985390

#TimeUsernameProblemLanguageResultExecution timeMemory
985390user736482Cave (IOI13_cave)C++17
100 / 100
579 ms792 KiB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
bool fixed_[5000];
int match[5000],result[5000],openstate,ak;
void change(int a, int b, bool c){
    for(int i=a;i<=b;i++){
        if(!fixed_[i])
            result[i]= c;
    }
}

void exploreCave(int n){
    for(int i=0;i<n;i++){
        int pocz=0;
        int kon=n-1;
        change(pocz,kon,1);
        ak=tryCombination(result);
        if(ak==i)
            openstate=0;
        else
            openstate=1;
        while(pocz<kon){
            int sr=(pocz+kon)/2;
            change(0,sr,openstate);
            change(sr+1,n-1,!openstate);
            ak=tryCombination(result);
            if(ak==i)
                pocz=sr+1;
            else
                kon=sr;
        }
        result[pocz]=openstate;
        match[pocz]=i;
        fixed_[pocz]=1;
    }
    answer(result,match);
}
#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...