Submission #697897

#TimeUsernameProblemLanguageResultExecution timeMemory
697897grossly_overconfidentCombo (IOI18_combo)C++17
100 / 100
32 ms528 KiB
#include "combo.h"
using namespace std;
#define endl "\n"


string guess_sequence(int N) {
    char A, B, X, Y;
    if (press("AB") != 0){
        if (press("B") == 1){
            A = 'B';
            B = 'A';
            X = 'X';
            Y = 'Y';
        }
        else{
            A = 'A';
            B = 'B';
            X = 'X';
            Y = 'Y';
        }
    }
    else if (press("X") != 0){
        A = 'X';
        B = 'B';
        X = 'A';
        Y = 'Y';
    }
    else{
        A = 'Y';
        B = 'B';
        X = 'X';
        Y = 'A';
    }
    string S = "";
    S += A;
    if (N == 1){
        return S;
    }
    for (int i = 0; i < N - 2; ++i){
        int take = press(S + B + S + X + B + S + X + X + S + X + Y);
        if (take == i + 1){
            S += Y;
        }
        else if (take == i + 2){
            S += B;
        }
        else{
            S += X;
        }
    }
    if (press(S + B) == N){
        S += B;
    }
    else if (press(S + X) == N){
        S += X;
    }
    else{
        S += Y;
    }

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