Submission #87131

#TimeUsernameProblemLanguageResultExecution timeMemory
87131solimm4sks콤보 (IOI18_combo)C++14
0 / 100
1 ms200 KiB
#include <combo.h>

std::string guess_sequence(int N)
{
    using namespace std;

    int n = N;
    string str = "";
    char first;

    {
        int x, y;
        x = press("AB");
        y = press("BX");

        if(x == 0 && y == 0){
            first = 'Y';
        }
        if(x == 1 && y == 0){
            first = 'A';
        }
        if(x == 0 && y == 1){
            first = 'X';
        }
        if(x == 1 && y == 1){
            first = 'B';
        }
    }
    str += first;

    if(first == 'Y'){
        for(int i = 0; i < n - 1; ++i){
            int delta = str.size();
            int x = press(str + "A" + str + "BA" + str + "BB" + str + "BX");

            if(x - delta == 0){
                str += "X";
            }
            if(x - delta == 1){
                str += "A";
            }
            if(x - delta == 2){
                str += "B";
            }
        }
    }
    if(first == 'A'){
        for(int i = 0; i < n - 1; ++i){
            int delta = str.size();
            int x = press(str + "Y" + str + "BY" + str + "BB" + str + "BX");

            if(x - delta == 0){
                str += "X";
            }
            if(x - delta == 1){
                str += "Y";
            }
            if(x - delta == 2){
                str += "B";
            }
        }
    }
    if(first == 'X'){
        for(int i = 0; i < n - 1; ++i){
            int delta = str.size();
            int x = press(str + "A" + str + "BA" + str + "BB" + str + "BY");

            if(x - delta == 0){
                str += "Y";
            }
            if(x - delta == 1){
                str += "A";
            }
            if(x - delta == 2){
                str += "B";
            }
        }
    }
    if(first == 'B'){
        for(int i = 0; i < n - 1; ++i){
            int delta = str.size();
            int x = press(str + "A" + str + "XA" + str + "XX" + str + "XY");

            if(x - delta == 0){
                str += "Y";
            }
            if(x - delta == 1){
                str += "A";
            }
            if(x - delta == 2){
                str += "X";
            }
        }
    }

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