Submission #1014994

# Submission time Handle Problem Language Result Execution time Memory
1014994 2024-07-05T22:16:46 Z Mardonbekhazratov Cave (IOI13_cave) C++17
0 / 100
346 ms 348 KB
#include "cave.h"
#include<iostream>

const int maxN=5e3+1;

int n;
int S[maxN],D[maxN];

void solve(int x){
    for(int i=0;i<n;i++){
        if(D[i]==-1) S[i]=0;
    }
    int ans=tryCombination(S);
    if(ans==x){
        int l=0,r=n-1;
        while(r>l){
            int mid=(l+r)/2;
            for(int j=0;j<=mid;j++){
                if(D[j]==-1) S[j]=1;
            }
            if(tryCombination(S)==x+1) r=mid;
            else l=mid+1;
            for(int j=0;j<=mid;j++){
                if(D[j]==-1) S[j]=0;
            }
        }
        D[l]=x;
        S[l]=0;
        return;
    }
    int l=0,r=n-1;
        while(r>l){
            int mid=(l+r)/2;
            for(int j=0;j<=mid;j++){
                if(D[j]==-1) S[j]=1;
            }
            if(tryCombination(S)==x) r=mid;
            else l=mid+1;
            for(int j=0;j<=mid;j++){
                if(D[j]==-1) S[j]=0;
            }
        }
        D[l]=x;
        S[l]=1;
}

void exploreCave(int N) {
    n=N;
    for(int i=0;i<n;i++) D[i]=-1,S[i]=-1;
    for(int i=0;i<n;i++){
        solve(i);
    }
    answer(S,D);
}
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 346 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 224 ms 348 KB Answer is wrong
2 Halted 0 ms 0 KB -