Submission #584637

#TimeUsernameProblemLanguageResultExecution timeMemory
584637supercatexCombo (IOI18_combo)C++11
100 / 100
34 ms636 KiB
#include <bits/stdc++.h>
using namespace std;

int press(string);

string guess_sequence(int N)
{
    string p = "", c = "";
    if (press("AB") > 0)
        if (press("A") > 0) p = "A", c = "BXY";
        else p = "B", c = "AXY";
    else
        if (press("X") > 0) p = "X", c = "ABY";
        else p = "Y", c = "ABX";

    int x = 1;
    while (x < N - 1) {
        string pp = p + c[0];   // c[0] return x + 1
        pp += p + c[1] + c[0];  // c[1] return x + 2
        pp += p + c[1] + c[1];  // c[2] return x
        pp += p + c[1] + c[2];
        int xx = press(pp);
        if (xx == x) p = p + c[2];
        else if (xx == x + 1) p = p + c[0];
        else p = p + c[1];
        x++;
    }
    
    if (x < N) {
        if (press(p + c[0]) > x) p = p + c[0];
        else if (press(p + c[1]) > x) p = p + c[1];
        else p = p + c[2];
    }
    return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...