Submission #1148877

#TimeUsernameProblemLanguageResultExecution timeMemory
1148877andrejikusCombo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) { cerr << to_string(h); if(sizeof...(t)) cerr << ", "; DBG(t...); }
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)

const int N = 2e5 + 3;
char ELEM[4] = {'A', 'B', 'X', 'Y'};

string guess_sequence(int n) {

    string s = "";
    string p = string(1, ELEM[0]) + string(1, ELEM[1]);
    if (press(p) > 0) {
        string c = string(1, ELEM[0]);
        if (press(c))
            s += c;
        else
            s += string(1, ELEM[1]);
    } else {
        string c = string(1, ELEM[2]);
        if (press(c))
            s += c;
        else
            s += string(1, ELEM[3]);
    }
    /// 3 qry

    for (int i = 2; i <= n; i++) {
        vector<char> vec;
        for (int d = 0; d < 4; d++)
            if (s[0] != ELEM[d])
                vec.push_back(ELEM[d]);
        if (i < n) {
            string p = s + vec[0] + s + vec[1] + vec[0] + s + vec[1] + vec[1] + s + vec[1] + vec[2];
            if (press(p) == i) {
                s += vec[0];
            } else if (press(p) == i+1) {
                s += vec[1];
            } else {
                s += vec[2];
            }
        } else {
            string p = string(1, ELEM[0]) + string(1, ELEM[1]);
            if (press(p) > 0) {
                string c = string(1, ELEM[0]);
                if (press(c))
                    s += c;
                else
                    s += string(1, ELEM[1]);
            } else {
                string c = string(1, ELEM[2]);
                if (press(c))
                    s += c;
                else
                    s += string(1, ELEM[3]);
            }
        }
    }

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