Submission #1303695

#TimeUsernameProblemLanguageResultExecution timeMemory
1303695khbaCombo (IOI18_combo)C++20
100 / 100
12 ms480 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;


int ask(string p)
{
    // cout << p << '\n';
    return press(p);
}

string guess_sequence(int n)
{
    // first letter
    string ans = "", lets = "";
    if (ask("AB")) {
        if (ask("A")) ans.append("A"), lets = "BXY";
        else ans.append("B"), lets = "AXY";
    }
    else if (ask("X")) ans.append("X"), lets = "ABY";
    else ans.append("Y"), lets = "ABX";
    for (int i = 1; i < n - 1; ++i)
    {
        int p = ask(ans + lets[0] + ans + lets[1] + lets[0] + ans + lets[1] + lets[1] + ans + lets[1] + lets[2]); 
        if (p == i + 1) ans += lets[0];
        else if (p == i + 2) ans += lets[1];
        else ans += lets[2];
    }
    if (n > 1) {
        if (ask(ans + lets[0]) == n) ans += lets[0];
        else if (ask(ans + lets[1]) == n) ans += lets[1];
        else ans += lets[2];
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...