Submission #138798

#TimeUsernameProblemLanguageResultExecution timeMemory
138798NnandiCombo (IOI18_combo)C++14
100 / 100
74 ms1536 KiB
#include "combo.h"
using namespace std;

string base = "ABXY";

string guess_sequence(int N) {
    string S;
    if(press("AB") == 0) {
      S = (press("X") == 0) ? "Y" : "X";
    }
    else {
      S = (press("A") == 0) ? "B" : "A";
    }
    if(N == 1) {
        return S;
    }
    string ord = S;
    for(char c:base) {
        if(c != S[0]) {
            ord.push_back(c);
        }
    }
    for(int i=1;i<N-1;i++) {
        string k;
        k = k + S + ord.substr(1,1) + ord.substr(1,1);
        k = k + S + ord.substr(1,1) + ord.substr(2,1);
        k = k + S + ord.substr(1,1) + ord.substr(3,1);
        k = k + S + ord.substr(2,1);
        int fr = press(k);
        if(fr == i) S.push_back(ord[3]);
        else if(fr == i+1) S.push_back(ord[2]);
        else S.push_back(ord[1]);
    }
    if(press(S + ord.substr(1,1)) == N) {
      S = S + ord.substr(1,1);
    }
    else {
      S = (press(S + ord.substr(2,1)) == N) ? S + ord.substr(2,1) : S + ord.substr(3,1);
    }
    return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...