Submission #1350006

#TimeUsernameProblemLanguageResultExecution timeMemory
1350006waygonzCombo (IOI18_combo)C++20
100 / 100
5 ms604 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
    string ans;
    char f;
    int t1 = press("AB");
    if (t1) {
        int t2 = press("A");
        if (t2) f = 'A';
        else f = 'B';
    } else {
        int t2 = press("X");
        if (t2) f = 'X';
        else f = 'Y';
    }
    ans += f;
    if (N == 1) return ans;
    vector<char> a;
    string it = "ABXY";
    for (auto e : it) if (e != f) a.emplace_back(e);
    while (ans.size() != N-1) {
        string g1 = ans + a[0];
        string g2 = ans + a[1] + a[0];
        string g3 = ans + a[1] + a[1];
        string g4 = ans + a[1] + a[2];
        int t = press(g1 + g2 + g3 + g4);
        if (t == ans.size()) ans += a[2];
        else if (t == ans.size() + 1) ans += a[0];
        else ans += a[1];
    }
    int t3 = press(ans + a[0]);
    int t4 = press(ans + a[1]);
    if (t3 == N) return ans + a[0];
    else if (t4 == N) return ans + a[1];
    else return ans + a[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...