Submission #769148

#TimeUsernameProblemLanguageResultExecution timeMemory
769148pashkaCombo (IOI18_combo)C++14
0 / 100
0 ms208 KiB
#include "combo.h"

char guess_first_letter() {
    int x = press("AB");
    if (x == 1) {
        int y = press("A");
        if (y == 1) {
            return 'A';
        } else {
            return 'B';
        }
    } else {
        int y = press("X");
        if (y == 1) {
            return 'X';
        } else {
            return 'Y';
        }
    }
}

std::string guess_sequence(int N) {
    std::string s;
    s += guess_first_letter();
    std::string chars;
    for (char c : "ABXY") {
        if (c != s[0]) chars += c;
    }
    for (int i = 0; i < N - 2; i++) {
        int x = press(
                s + chars[0] + chars[0] +
                        s + chars[0] + chars[1] +
                        s + chars[0] + chars[2] +
                        s + chars[1]);
        if (x == 0) {
            s += chars[2];
        } else if (x == 1) {
            s += chars[1];
        } else {
            s += chars[0];
        }
    }
    int x = press(s + chars[0] + s + chars[1]);
    if (x == N) {
        x = press(s + chars[0]);
        if (x == N) {
            return s + chars[0];
        } else {
            return s + chars[1];
        }
    } else {
        return s + chars[2];
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...