Submission #1209265

#TimeUsernameProblemLanguageResultExecution timeMemory
1209265AksLolCodingCombo (IOI18_combo)C++17
97 / 100
7 ms524 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

// const string S = "A";
// int queries = 0;

// int press(string p) {
//     queries++;
//     int n = S.size();
//     for (int i = n; i > 0; i--) {
//         if (p.find(S.substr(0, i)) != string::npos) {
//             return i;
//         }
//     }
//     return 0;
// }

char chars[] = "ABXY";
string guess_sequence(int n) {
    for (int i = 0; i < 3; i++)
        if (press({chars[i]}) == 1) {
            swap(chars[i], chars[3]);
            break;
        }

    string res = {chars[3]};
    for (int i = 1; i < n-1; i++) {
        string p = res + chars[0];
        for (int i = 0; i < 3; i++) p += res + chars[1] + chars[i];
        int x = press(p);
        res += chars[(x == i) ? 2 : (x == i + 1) ? 0 : 1];
    }

    if (n == 1) return res;

    for (int i = 0; i < 2; i++) {
        if (press(res + chars[i]) == n) {
            res += chars[i];
            break;
        }
    }
    if (res.size() < n) res += chars[2];
    return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...