Submission #1303683

#TimeUsernameProblemLanguageResultExecution timeMemory
1303683khbaCombo (IOI18_combo)C++20
5 / 100
1 ms400 KiB
#include "combo.h"
#include "iostream"

using namespace std;

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

string guess_sequence(int n)
{
    // first letter
    string ans = "";
    if (ask("AB")) ans += ask("A") ? "A" : "B";
    else ans += ask("X") ? "X" : "Y";
    for (int i = 1; i < n - 1; ++i)
    {
        string s = "";
        bool vis = false;
        for (char c : string("ABXY"))
            if (ans.front() != c)
            {
                if (s.empty())
                    s += ans + c;
                else if (vis == false)
                {
                    vis = true;
                    for (char cc : string("ABXY")) if (ans.front() != cc) s += ans + c, s += cc;
                    int g = ask(s);
                    if (g == ans.size() + 1)
                    {
                        ans = s.substr(0, ans.size() + 1);
                        break;
                    }
                    if (g == ans.size() + 2)
                    {
                        ans += c;
                        break;
                    }
                }
                else
                    ans += c;
            }
    }
    string lets = "";
    for (char c : string("ABXY")) if (ans.front() != c) lets += c;
    // cout << ans << ' ' << lets << '\n';
    if (ask(ans + lets[0] + ans + lets[1]) == n) ans += ask(ans + lets[0]) == n ? lets[0] : lets[1];
    else ans += lets[2];
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...