제출 #1339853

#제출 시각아이디문제언어결과실행 시간메모리
1339853chry콤보 (IOI18_combo)C++20
10 / 100
17 ms788 KiB
#include <bits/stdc++.h>
using namespace std;

char choices[4] = {'A', 'B', 'X', 'Y'};

int press(string p);

string guess_sequence(int N) {
    string S = "";
    
    function<bool(int)> dfs = [&](int now) -> bool {
        for (int i = 0; i < 4; i++) {
            if ((!S.empty()) && choices[i] == S[0]) continue;
            int pp = press(S+choices[i]);
            if (pp != N && pp > now) {
                S += choices[i];
                if (dfs(now+1)) return true;
                S.pop_back();
            } else if (pp == N) {
                S += choices[i];
                return true;
            }
        }
        return false;
    };

    dfs(0);

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