Submission #161107

#TimeUsernameProblemLanguageResultExecution timeMemory
161107giorgikobCombo (IOI18_combo)C++14
100 / 100
55 ms544 KiB
#include "combo.h"
#include <string>
std::string guess_sequence(int N) {
    std::string S = "";
    
    int x = press("AB");
    if(x >= 1){
        x = press("A");
        if(x==1){
            S = "A";//cout<<S<<endl;
        } else {
            S = "B";
        }
    } else {
        x = press("X");
        if(x==1){
            S = "X";
        } else {
            S = "Y";
        }
    }
    
  	if(N==1)return S;
  
    std::string c1,c2,c3;
    if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
    if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
    if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
    if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
    
    for(int i=2;i<=N-1;i++){
        std::string p = S+c1+S+c2+c1+S+c2+c2+S+c2+c3;
        int x = press(p);
        if(x==i-1)
        S += c3;
        if(x==i)
        S += c1;
        if(x==i+1)
        S += c2;
    }
    
    std::string p = S + c1 + S + c2;
     x = press(p);
    if(x == N){
        p = S + c1;
        x = press(p);
        if(x==N){
            S += c1;
        } else {
            S += c2;
        }
    } else {
        S += c3;
    }
    //printf("%s",S);
    return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...