제출 #813256

#제출 시각아이디문제언어결과실행 시간메모리
813256Pikachu콤보 (IOI18_combo)C++17
0 / 100
0 ms208 KiB
#include <bits/stdc++.h>

using namespace std;

template<typename T>
inline bool maxi(T &x, const T &val)
{
    if (x < val) return x = val, true;
    return false;
}

template<typename T>
inline bool mini(T &x, const T &val)
{
    if (x > val) return x = val, true;
    return false;
}

int press(string p);
char c[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int n)
{
    string ans = "";
    if (press("AB")) {
        if (press("A")) ans += "A";
        else ans += "B", swap(c[0], c[1]);
    }
    if (n == 1) return ans;
    else {
        if (press("X")) ans += "X", swap(c[0], c[2]);
        else ans += "Y", swap(c[0], c[3]);
    }
    while ((int)ans.size() < n - 1) {
        string tmp = "";
        for (int i = 1; i <= 3; i++) {
            tmp += (ans + c[1] + c[i]);
        }
        tmp += (ans + c[2]);
        int dak = press(tmp);
        if (dak == (int)ans.size()) {
            ans += c[3];
        }
        else if (dak == (int)ans.size() + 1) {
            ans += c[2];
        }
        else ans += c[1];
    }
    if (press(ans + c[1]) == n) return ans + c[1];
    if (press(ans + c[2]) == n) return ans + c[2];
    return ans + c[3];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...