Submission #555624

#TimeUsernameProblemLanguageResultExecution timeMemory
555624cheissmartCombo (IOI18_combo)C++14
5 / 100
1 ms240 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
  cerr << to_string(h);
  if(sizeof ...(t)) cerr << ", ";
  DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7;

string guess_sequence(int N) {
    string s;
    auto add_one = [&] () {
        string t = s + "A" + s + "B";
        if(press(t) > SZ(s)) {
            if(press(s + "A") > SZ(s))
                s += "A";
            else
                s += "B";
        } else {
            if(press(s + "X") > SZ(s))
                s += "X";
            else
                s += "Y";
        }
    };
    add_one();

    string c;
    for(char cc:"ABXY") if(cc != s[0]) c.PB(cc);

    while(SZ(s) + 2 <= N) {
        string t = s + c[0] + c[0] + s + c[0] + c[1] + s + c[0] + c[2] + s + c[1];
        int tt = press(t);
        if(tt == SZ(s)) 
            s += c[2];
        else if(tt == SZ(s) + 1)
            s += c[1];
        else
            s += c[0];
    }
    add_one();
    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...