Submission #876999

#TimeUsernameProblemLanguageResultExecution timeMemory
876999AlphaMale06Cave (IOI13_cave)C++14
12 / 100
125 ms604 KiB
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;

void exploreCave(int n){
    bool know[n];
    int p[n], ans[n], comb[n];
    for(int i=0; i< n; i++){
        know[i]=ans[i]=0;
    }
    for(int i=0; i< n; i++){
        for(int j=0; j< n; j++)comb[j]=ans[j];
        int l=0; int r=n-1;
        int prev=tryCombination(comb);
        while(l<r){
            int s=(l+r)/2;
            for(int j=l; j<=s; j++){
                if(!know[j])comb[j]=1-comb[j];
            }
            int ans1=tryCombination(comb);
            if(ans1==prev)l=s+1;
            else r=s;
            prev=ans1;
        }
        know[l]=1;
        p[i]=l;
        if(prev==i)ans[l]=1-comb[l];
        else ans[l]=comb[l];
    }
    answer(ans, p);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:9:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
    9 |         know[i]=ans[i]=0;
      |                 ~~~~~~^~
#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...