Submission #553114

#TimeUsernameProblemLanguageResultExecution timeMemory
553114pckienCombo (IOI18_combo)C++17
100 / 100
33 ms700 KiB
#include <bits/stdc++.h>
#define fto(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;

int n;

int press(string p);


string guess_sequence(int n){
    string G, hoho, haha, haha1, haha2, haha3, hehe;
    int trai = press("AB"), phai = press("XA");

    if (trai && phai){
        G = "A";
    } else
    if (trai > phai){
        G = "B";
    } else
    if (trai < phai){
        G = "X";
    } else G = "Y";

    if (n == 1){
        return G;
    }

    if (G == "A"){
        hoho = "B";
        haha = "X";
        haha1 = "XB";
        haha2 = "XX";
        haha3 = "XY";
        hehe = "Y";
    }
    if (G == "B"){
        hoho = "A";
        haha = "X";
        haha1 = "XA";
        haha2 = "XX";
        haha3 = "XY";
        hehe = "Y";
    }
    if (G == "X"){
        hoho = "A";
        haha = "B";
        haha1 = "BA";
        haha2 = "BB";
        haha3 = "BY";
        hehe = "Y";
    }
    if (G == "Y"){
        hoho = "A";
        haha = "B";
        haha1 = "BA";
        haha2 = "BB";
        haha3 = "BX";
        hehe = "X";
    }

    fto(i, 2, n-1){
        string tmp = G + hoho + G + haha1 + G + haha2 + G + haha3;
        int get = press(tmp), sz = G.size();
        if (get == sz + 1){
            G = G + hoho;
        } else
        if (get == sz + 2){
            G = G + haha;
        } else G = G + hehe;
        //cout << G << endl;
    }

    string l = G + hoho + G + hehe, r = G + haha + G + hoho;
    trai = press(l), phai = press(r);

    if (trai == phai){
        G = G + hoho;
    } else
    if (trai > phai){
        G = G + hehe;
    } else G = G + haha;

    return G;
}

#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...