Submission #839661

#TimeUsernameProblemLanguageResultExecution timeMemory
839661sleepntsheepCombo (IOI18_combo)C++17
100 / 100
29 ms540 KiB
#include "combo.h"
#include <cassert>
#include <string>
#include <vector>
using namespace std;

string guess_sequence(int N)
{
    string S, opt;

    if (press("AB"))
    {
        if (press("A")) opt="BXY", S="A";
        else opt="AXY", S="B";
    }
    else
    {
        if (press("X")) opt="ABY", S="X";
        else opt="ABX", S="Y";
    }

    if (N == 1) return S;

    for (int i = 1; i < N - 1; ++i)
    {
        string ask = S + opt[0] + opt[0] + S + opt[0] + opt[1] + S + opt[0] + opt[2]  + S + opt[1];
        int k = press(ask);
        if (k == i + 2) S += opt[0];
        else if (k == i + 1) S += opt[1];
        else S += opt[2];
    }

    if (press(S+opt[0])==N) S+=opt[0];
    else if (press(S+opt[1])==N) S+=opt[1];
    else S+=opt[2];

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