Submission #1317914

#TimeUsernameProblemLanguageResultExecution timeMemory
1317914shangbinCombo (IOI18_combo)C++20
100 / 100
8 ms620 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N){
    vector<string> b = {"A", "B", "X", "Y"};
    string p, S = "";
    int first;
    if (press("XY") >= 1){
        if (press("X") == 1) first = 2;
        else first = 3;
    }
    else {
        if (press("A") == 1) first = 0;
        else first = 1;
    }
    S += b[first];
    if (N == 1) return S;
    b.erase(b.begin() + first);
    for (int i = 1; i < N-1; i++){
        p = (S + b[1]) + (S + b[2] + b[0]) + (S + b[2] + b[1]) + (S + b[2] + b[2]);
        S += b[press(p) - S.length()];
    }
    if (press(S + b[0]) == N) S += b[0];
    else if (press(S + b[1]) == N) S += b[1];
    else S += b[2];
    return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...