Submission #293843

#TimeUsernameProblemLanguageResultExecution timeMemory
293843KastandaCombo (IOI18_combo)C++11
100 / 100
31 ms648 KiB
// M
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
string G[4] = {"A", "B", "X", "Y"};

string guess_sequence(int n)
{
        if (!press("AB"))
                swap(G[0], G[2]), swap(G[1], G[3]);
        if (!press(G[0]))
                swap(G[0], G[1]);

        string Rs = G[0];
        if (n == 1)
                return Rs;
        for (int i = 1; i < n - 1; i ++)
        {
                string P = Rs + G[1] + G[1] + Rs + G[1] + G[2] + Rs + G[1] + G[3] + Rs + G[2];
                int c = press(P) - (int)Rs.size();
                if (c == 0)
                        Rs += G[3];
                else if (c == 1)
                        Rs += G[2];
                else
                        Rs += G[1];
        }
        if (press(Rs + G[1]) == n)
                Rs += G[1];
        else if (press(Rs + G[2]) == n)
                Rs += G[2];
        else
                Rs += G[3];
        return Rs;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...