Submission #1325607

#TimeUsernameProblemLanguageResultExecution timeMemory
1325607pramad712Combo (IOI18_combo)C++20
30 / 100
11 ms444 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

std::string guess_sequence(int length) {
    char first = 'Y';

    if (press("A")) first = 'A';
    else if (press("B")) first = 'B';
    else if (press("X")) first = 'X';

    vector<char> next_options;
    for (char next: vector{'A', 'B', 'X', 'Y'}) if (next != first) next_options.push_back(next);

    string known; known.push_back(first);

    for (int index = 2; index <= length; index++) {
        if (press(known + next_options[0]) == index) {
            known += next_options[0];
        }

        else if (press(known + next_options[1]) == index) {
            known += next_options[1];
        }

        else {
            known += next_options[2];
        }
    }

    return known;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...