Submission #837728

#TimeUsernameProblemLanguageResultExecution timeMemory
837728FulopMateCombo (IOI18_combo)C++17
100 / 100
22 ms596 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {
    int n = N;
    if(n == 1){
        int a = press("A"), b = press("B"), x = press("X");
        if(a)return "A";
        if(b)return "B";
        if(x)return "X";
        return "Y";
    }
    string ans = "";
    vector<string> marad;
    int x = press("AB");
    if(x){
        x = press("A");
        if(x){
            ans = "A";
            marad = {"B","X","Y"};
        } else {
            ans = "B";
            marad = {"A","X","Y"};
        }
    } else {
        x = press("X");
        if(x){
            ans = "X";
            marad = {"A","B","Y"};
        } else {
            ans = "Y";
            marad = {"A","B","X"};
        }
    }
    string marad1 = string(marad[0]), marad2 = string(marad[1]), marad3 = string(marad[2]);
    for(int i = 1; i < n-1; i++){
        x = press(ans+marad1 + ans+marad2+marad1 + ans+marad2+marad2 + ans+marad2+marad3);
        if(x == i){
            ans += marad3;
        } else if(x == i+1){
            ans += marad1;
        } else {
            ans += marad2;
        }
    }
    x = press(ans+marad1);
    if(x == n){
        return ans + marad1;
    }
    x = press(ans+marad2);
    if(x == n){
        return ans + marad2;
    }
    return ans + marad3;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...