Submission #985337

#TimeUsernameProblemLanguageResultExecution timeMemory
985337user736482Cave (IOI13_cave)C++17
0 / 100
16 ms348 KiB
#include<bits/stdc++.h>
#include<cave.h>
using namespace std;
int match[5002],sent[5002];
bool openstate,fixed_[5002];
int ak;
void change(int a, int b, int c){
    for(int i=a;i<=b;i++){
        if(!fixed_[i])
            sent[i]= c;
    }
}

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