Submission #848721

#TimeUsernameProblemLanguageResultExecution timeMemory
848721toma_ariciuCombo (IOI18_combo)C++17
100 / 100
16 ms2196 KiB
#include <string>

using namespace std;

string c[3], str, aux;

int press(string p);

void initC(string x, string y, string z) {
    c[0] = x;
    c[1] = y;
    c[2] = z;
}

string guess_sequence(int N) {
    int x = press("AB"), y;
    if (x > 0) {
        y = press("A");
        if (y > 0) {
            str = "A";
            initC("B", "X", "Y");
        }
        else {
            str = "B";
            initC("A", "X", "Y");
        }
    }
    else {
        y = press("X");
        if (y > 0) {
            str = "X";
            initC("A", "B", "Y");
        }
        else {
            str = "Y";
            initC("A", "B", "X");
        }
    }
    if (N == 1) {
        return str;
    }
    for (int i = 2; i < N; i++) {
        aux = str + c[0];
        for (int j = 0; j < 3; j++) {
            aux = aux + str + c[1] + c[j];
        }
        x = press(aux);
        if (x == i - 1) {
            str = str + c[2];
        }
        if (x == i) {
            str = str + c[0];
        }
        if (x == i + 1) {
            str = str + c[1];
        }
    }
    for (int i = 0; i < 2; i++) {
        aux = str + c[i];
        x = press(aux);
        if (x == N) {
            return aux;
        }
    }
    aux = str + c[2];
    return aux;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...