Submission #1317006

#TimeUsernameProblemLanguageResultExecution timeMemory
1317006marzuq01Combo (IOI18_combo)C++20
30 / 100
16 ms444 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";
    }
    std::string temp;
    for (auto i: alp) if (i != ans[0]) temp += i;
    //int tindex = 0; //012
    while(ans.size() < N) {
        int now = ans.size();
        char last = ans.back();
        for (auto i: temp) {
            if (i == last) continue;
            std::string s = ans;
            for (int c = 0; c < N;c++) s += (char)i;
            //std::cout << s << "\n";
            coin = press(s);
            if (coin > now) {
                for (int k = now + 1; k <= coin; k++) {
                    ans += i;
                }
                break;
            }
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...