Submission #1284551

#TimeUsernameProblemLanguageResultExecution timeMemory
1284551hynmjCombo (IOI18_combo)C++20
5 / 100
1 ms400 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
const string init = "ABXY";
vector<string> ist = {"B", "CA", "CB", "CC"};
std::string guess_sequence(int n)
{
    string s;
    for (int i = 0; i < 2; i++)
    {
        s += init[i];
    }
    int k = press(s);
    if (k == 0)
    {
        s = init[2];
        k = press(s);
        if (k == 0)
        {
            s = init[3];
        }
    }
    else
    {
        s = init[0];
        k = press(s);
        if (k == 0)
        {
            s = init[1];
        }
    }
    string t;
    for (int i = 0; i < 4; i++)
    {
        if (init[i] == s[0])
            continue;
        t += init[i];
    }
    vector<string> st = ist;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < ((int)st[i].size()); j++)
        {
            st[i][j] = t[ist[i][j] - 'A'];
        }
    }
    // cerr << " t = " << t << endl;
    for (int i = 0; s.size() < n - 1; i++)
    {

        // cerr << "uptill now  " << s << " and size = " << s.size() << endl;
        string q = "";
        for (int i = 0; i < 4; i++)
        {
            q += s;
            q += st[i];
        }
        // cout << "queried " << q << "  " << q.size() << endl;
        // cerr << "uptill now  " << s << " and size = " << s.size() << endl;
        k = press(q) - s.size();
        // cerr << "pressing button " << k << endl;
        // cerr << " t = " << t << endl;
        s += t[k];
    }
    string q;
    q += s;
    q += t[0];
    k = press(q) - s.size();
    if (k)
    {
        return q;
    }
    q.clear();
    q += s;
    q += t[1];
    k = press(q) - s.size();
    if (k)
    {
        return q;
    }
    q.clear();

    q += s;
    q += t[2];
    // cout << "returning " << q << endl;
    return q;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...