Submission #251057

#TimeUsernameProblemLanguageResultExecution timeMemory
251057defineCombo (IOI18_combo)C++17
100 / 100
43 ms856 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

string guess_sequence(int N) {
    string ans;
    int q=press("AB"),done=0;
    if(q==2){
        ans+="AB";
        N-=2;done+=2;
    }else if(q==1){
        int q=press("A");
        ans+=(q?"A":"B");
        N--;done++;
    }else {
        int q=press("X");
        ans+=(q?"X":"Y");
        N--;done++;
    }
    if(N==0)return ans;
    string choice="ABXY";
    rep(i,4){
        if(choice[i]==ans[0]){
            choice.erase(choice.begin()+i);break;
        }
    }
    rep(i,N-1){
        string query=ans+choice[0]+choice[0];
        query+=ans+choice[0]+choice[1];
        query+=ans+choice[0]+choice[2];
        query+=ans+choice[1];
        int q=press(query);
        if(q==done)ans+=choice[2];
        else if(q==done+1)ans+=choice[1];
        else ans+=choice[0];
        done++;
    }
    q=press(ans+"A"+ans+"B");
    if(q==done+1){
        q=press(ans+"A");
        ans+=(q==done+1?"A":"B");
    }else {
        q=press(ans+"X");
        ans+=(q==done+1?"X":"Y");
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...