Submission #374799

#TimeUsernameProblemLanguageResultExecution timeMemory
374799Alex_tz307콤보 (IOI18_combo)C++17
100 / 100
50 ms536 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int N) {
    string sol;
    int ok = press("AB");
    if(ok) {
        int first = press("A");
        if(first)
            sol = "A";
        else
            sol = "B";
    }
    else {
        int first = press("X");
        if(first)
            sol = "X";
        else
            sol = "Y";
    }
    string mask = "";
    for(const char &ch : "ABXY")
        if(ch != sol[0])
            mask += ch;
    if(N == 1)
        return sol;
    for(int i = 2; i < N; ++i) {
        string ask = sol + mask[0] + sol + mask[1] + mask[0] + sol + mask[1] + mask[1] + sol + mask[1] + mask[2];
        int lg = press(ask);
        if(lg == i)
            sol += mask[0];
        else
            if(lg == i + 1)
                sol += mask[1];
        else
            sol += mask[2];
    }
    if(press(sol + mask[0]) == N)
        return sol + mask[0];
    if(press(sol + mask[1]) == N)
        return sol + mask[1];
    return sol + mask[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...