Submission #1248777

#TimeUsernameProblemLanguageResultExecution timeMemory
1248777lrnnz콤보 (IOI18_combo)C++20
5 / 100
0 ms408 KiB
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <random>
#include "combo.h"
using namespace std;

#define all(a) (a).begin(), (a).end()
#define ll long long
#define ld long double
#define ui uint64_t
#define cont(set, element) ((set).find(element) != (set).end())
#define pb push_back

#define chmin(x, y) (x = min(x, y)) 
#define chmax(x, y) (x = max(x, y))

/********* DEBUG *********/

template <typename T>
void outvec(const vector<T>& Z){
    for (const T& x : Z)
    cout << x << ' ';
    cout << "\n";
}
void printVariable(const any& var) {
    if (!var.has_value()) {
        cout << "null";
        return;
    }

    if (var.type() == typeid(int)) {
        cout << any_cast<int>(var);
    } else if (var.type() == typeid(double)) {
        cout << any_cast<double>(var);
    } else if (var.type() == typeid(float)) {
        cout << any_cast<float>(var);
    } else if (var.type() == typeid(char)) {
        cout << any_cast<char>(var);
    } else if (var.type() == typeid(bool)) {
        cout << (any_cast<bool>(var) ? "true" : "false");
    } else if (var.type() == typeid(string)) {
        cout << any_cast<string>(var);
    } else if (var.type() == typeid(const char*)) {
        cout << any_cast<const char*>(var);
    } else if (var.type() == typeid(long long)) {
        cout << any_cast<long long>(var);
    } else {
        cout << "[unknown type]";
    }
}


template<typename... Args>
void outval(Args... args) {
    vector<any> variables = {args...};
    
    for (size_t i = 0; i < variables.size(); ++i) {
        printVariable(variables[i]);
        if (i != variables.size() - 1) {
            cout << " ";
        }
    }
    cout << "\n";
}

#define sp << " " <<
#define fi first
#define se second

/********* DEBUG *********/

const ll MOD2 = 1e9 + 7;
const ll MOD = 998244353;
const ll inf = 1e18;

string guess_sequence(int N) {
    string ans = "";
    if (press("AB")){
        if (press("A"))
            ans = "A";
        else
            ans = "B";
    }
    else{
        if (press("X"))
            ans = "X";
        else
            ans = "Y";
    }

    vector<char> ord(3);
    ll i = 0;
    if (ans[0] != 'A')
        ord[i++] = 'A';

    if (ans[0] != 'B')
        ord[i++] = 'B';

    if (ans[0] != 'X')
        ord[i++] = 'X';

    if (ans[0] != 'Y')
        ord[i++] = 'Y';

    for (int i = 0; i < N-2; i++){
        // N
        string in = ans;
        in += ord[1];

        // 2N
        in += ans;
        in += ord[2];
        in += ord[0];

        // 3N
        in += ans;
        in += ord[2];
        in += ord[1];

        // 4N
        in += ans;
        in += ord[2];
        in += ord[2];

        ll val = press(in);
        if (val == i+1)
            ans += ord[0];
        else if (val == i+2)
            ans += ord[1];
        else
            ans += ord[2];
    }

    ans += ord[0];
    if (press(ans) == N)
        return ans;

    ans.pop_back();
    ans += ord[1];
    if (press(ans) == N)
        return ans;

    ans.pop_back();
    ans += ord[2];

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