Submission #1317057

#TimeUsernameProblemLanguageResultExecution timeMemory
1317057marzuq01Combo (IOI18_combo)C++20
100 / 100
9 ms464 KiB
#include "combo.h"

std::string guess_sequence(int N) {
    std::string ans;
    //std::string s;
    std::string alp = "ABXY";
    int coin;
    coin = press("AB");
    if(coin) {
        coin = press("A");
        if (coin) ans = "A";
        else ans = "B";
    } else {
        coin = press("X");
        if (coin) ans = "X";
        else ans = "Y";
    }
    if (N == 1) return ans;
    std::string temp;
    for (auto i: alp) if (i != ans[0]) temp += i;
    //int tindex = 0; //012
    while(ans.size() < N-1) {
        int now = ans.size();
        std::string s = ans + temp[0] + temp[1] +ans+ temp[0] + temp[2] +ans+ temp[0] + temp[0] + ans + temp[1];
        coin = press(s);
        if (coin == now) ans += temp[2];
        else if (coin == now + 1) ans += temp[1];
        else ans += temp[0];
    }
    if (press(ans + temp[0]) == N) ans += temp[0];
    else if (press(ans + temp[1]) == N) ans += temp[1];
    else ans += temp[2];
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...