Submission #1099717

#TimeUsernameProblemLanguageResultExecution timeMemory
1099717NinedesuCave (IOI13_cave)C++14
0 / 100
169 ms540 KiB
#include "cave.h"
#include<bits/stdc++.h>
using namespace std;

void exploreCave(int N) {
    int test[N],lock[N],pos[N],D[N];
    for(int i=0; i<N; i++){
        lock[i] = -1;
    }
    for(int i=0; i<N; i++){
        int thisans;
        for(int j=0; j<N; j++){
            if(lock[j]!=-1)test[j] = lock[j];
            else test[j] = 0;
        }
        int door = tryCombination(test);
        thisans = (door == i);
        int l=0,r=N-1;
        while(l<r){
            int mid=(l+r)/2;
            for(int j=i; j<=mid; j++){
                if(lock[j]!=-1)test[j] = lock[j];
                else test[j] = 0;
            }
            for(int j=mid+1; j<=r; j++){
                if(lock[j]!=-1)test[j] = lock[j];
                else test[j] = 1;
            }
            door = tryCombination(test);
            if(door > i || i==-1){
                if(!thisans){
                    r=mid;
                }
                else{
                    l=mid+1;
                }
            }
            else{
                if(!thisans){
                    l=mid+1;
                }
                else{
                    r=mid;
                }
            }
        }
        pos[i]=l;
        lock[l]=thisans;
    }
    for(int i=0; i<N; i++){
        D[pos[i]]=i;
    }
    answer(lock,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...