Submission #783271

#TimeUsernameProblemLanguageResultExecution timeMemory
783271sadsaCombo (IOI18_combo)C++17
30 / 100
39 ms448 KiB
#include "combo.h"

#include <bits/stdc++.h>
using namespace std;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

using i64 = int64_t;
using vl = vector<i64>;
using ll = pair<i64, i64>;
using vll = vector<ll>;

constexpr int iINF = numeric_limits<int>::max();
constexpr i64 lINF = numeric_limits<i64>::max();

#define RANGE(x) begin(x), end(x)

template <typename... T>
void DBG(T&&... args) {
    ((cerr << args << ' '), ...) << '\n';
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
    out << '{';
    for (size_t i = 0; i < vec.size()-1; ++i)
        out << vec[i] << ", ";
    out << vec.back() << '}';
    return out;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &pr) {
    out << '(' << pr.first << ", " << pr.second << ')';
    return out;
}

std::string guess_sequence(int N) {
    vector<char> chars{'A', 'B', 'X'};
    string p;
    for (char c : chars) {
        if (press(string(1, c))) {
            p = string(1, c);
            break;
        }
    }

    if (p.empty()) {
        p = string(1, 'Y');
    } else {
        chars.erase(find(RANGE(chars), p[0]));
        chars.push_back('Y');
    }

    char o = chars.back();
    chars.pop_back();

    for (int i = 1; i < N; ++i) {
        bool f=false;
        for (char c : chars) {
            if (press(p + c) == i+1) {
                p += c;
                f=true;
                break;
            }
        }
        if (!f)
            p += o;
    }
    //DBG(p);
    return p;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...