Submission #171694

#TimeUsernameProblemLanguageResultExecution timeMemory
171694triple_faultCombo (IOI18_combo)C++14
5 / 100
2 ms256 KiB
#include "combo.h"
#include <vector>

std::string guess_sequence(int N) {
    std::string S = "";
    std::string fc = "";
    if (press("A")) fc = "A";
    else if (press("B")) fc = "B";
    else if (press("X")) fc = "X";
    else fc = "Y";
    S = fc;

    std::vector<std::string> oops = {"A", "B", "X", "Y"}; 
    std::vector<std::string> chars;
    for (auto &each: oops) 
        if (each != fc) chars.push_back(each);

    for (int n = 2; n < N; ++n) {
        std::string p = "";
        p += S + chars[0] + S + chars[1] + chars[0] + S + chars[1] + chars[1] 
            + S + chars[1] + chars[2];
        int ret = press(p);
        if (ret == n) S += chars[0];
        else if (ret == (n + 1)) S += chars[1];
        else S += chars[2];
    }

    std::string p1 = S + chars[0];
    std::string p2 = S + chars[1];
    if (press(p1) == N) return p1;
    else if (press(p2) == N) return p2;
    else return S + chars[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...