Submission #1018053

#TimeUsernameProblemLanguageResultExecution timeMemory
1018053Sho10Combo (IOI18_combo)C++17
5 / 100
1 ms344 KiB
#include "combo.h"
#include <iostream>
#include <bitset>

using namespace std;

int n;

char start;
string others;

void get_start() {
    if (press("AB")) {
        if (press("A")) {
            start = 'A';
            others = "BXY";
        } else {
            start = 'B';
            others = "AXY";
        }
    } else {
        if (press("X")) {
            start = 'X';
            others = "ABY";
        } else {
            start = 'Y';
            others = "ABX";
        }
    }
}

string guess_sequence(int N) {
    n = N;
    get_start();

    string p = (string) "" + start;
    for (int i = 1; i < n - 1; i++) {
        int got = press(p + others[0] + p + others[1] + others[0] + p + others[1] + others[1] + p + others[1] + others[2]);
        switch (got - i) {
        case 0:
            p += others[2];
            break;
        case 1:
            p += others[0];
            break;
        case 2:
            p += others[1];
            break;
        }
    }

    if (press(p + others[0]) == n) return p + others[0];
    else if (press(p + others[1]) == n) return p + others[1];
    return p + others[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...