Submission #835312

#TimeUsernameProblemLanguageResultExecution timeMemory
835312mousebeaverCombo (IOI18_combo)C++14
91 / 100
23 ms700 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

std::string guess_sequence(int N) 
{
    vector<string> a = {"A", "B", "X", "Y"};

    int index = 0;
    while(press(a[index]) == 0)
    {
        index++;
    }

    string prefix = a[index];
    a.erase(a.begin()+index);
    if(N == 1)
    {
        return prefix;
    }

    while((int) prefix.length() < N-1)
    {
        string q = prefix + a[1] + prefix + a[2] + a[0] + prefix + a[2] + a[1] + prefix + a[2] + a[2];
        int res = press(q);
        if(res == (int) prefix.length())
        {
            prefix += a[0];
        }
        else if(res == (int) prefix.length()+1)
        {
            prefix += a[1];
        }
        else
        {
            prefix += a[2];
        }
    }

    index = 0;
    while(press(prefix+a[index]) < N)
    {
        index++;
    }
    prefix += a[index];

    return prefix;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...