Submission #877001

#TimeUsernameProblemLanguageResultExecution timeMemory
877001AlphaMale06Cave (IOI13_cave)C++14
100 / 100
158 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==i && prev==i) || (ans1!=i && prev!=i))l=s+1;
            else r=s;
            prev=ans1;
        }
        know[l]=1;
        p[l]=i;
        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...