Submission #1209261

#TimeUsernameProblemLanguageResultExecution timeMemory
1209261AksLolCodingCombo (IOI18_combo)C++17
5 / 100
0 ms408 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

// string S = "ABXYY";
// 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) {
    // find first char
    int first = 3;
    for (int i = 0; i < 3; i++) if (press({chars[i]}) == 1) {
        first = i;
        break;
    }
    swap(chars[first], chars[3]);

    // find rest
    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];
    }
    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...