Submission #1248719

#TimeUsernameProblemLanguageResultExecution timeMemory
1248719antonnCombo (IOI18_combo)C++20
100 / 100
8 ms484 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string guess_sequence(int n) {
    string s = "";
    if (press("AB") > 0) {
        if (press("A")) {
            s += "A";
        } else {
            s += "B";
        }
    } else {
        if (press("X")) {
            s += "X";
        } else {
            s += "Y";
        }
    }
    
    if (n == 1) return s;

    for (int i = 1; i < n - 1; ++i) {
        vector<char> c;
        for (auto ch : {'A', 'B', 'X', 'Y'}) {
            if (ch != s[0]) {
                c.push_back(ch);
            }
        }
        string query = s + c[0] + s + c[1] + c[0] + s + c[1] + c[1] + s + c[1] + c[2];
        int x = press(query);
        if (x == i) {
            s += c[2];
        } else if (x == i + 1) {
            s += c[0];
        } else {
            s += c[1];
        }
    }
    if (press(s + "A" + s + "B") == n) {
        if (press(s + "A") == n) {
            s += "A";
        } else {
            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...