제출 #717253

#제출 시각아이디문제언어결과실행 시간메모리
717253BackNoobCombo (IOI18_combo)C++14
0 / 100
0 ms208 KiB
#include "combo.h"
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define endl '\n'
#define MASK(i) (1LL << (i))
#define ull unsigned long long
#define ld long double
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define BIT(x , i) ((x >> (i)) & 1)
#define TASK "task"
#define sz(s) (int) (s).size()
 
using namespace std;
const int mxN = 5e5 + 227;
const int inf = 1e9 + 277;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 7;
const int base = 307;
const int LOG = 20;
 
template <typename T1, typename T2> bool minimize(T1 &a, T2 b) {
    if (a > b) {a = b; return true;} return false;
}
template <typename T1, typename T2> bool maximize(T1 &a, T2 b) {
    if (a < b) {a = b; return true;} return false;
}
 
string guess_sequence(int n)
{
    vector<char> f({'A', 'B', 'X', 'Y'});
    string res = "";
    string t1 = "";
    string t2 = "";
    t1 += f[0] + f[1];
    t2 += f[1] + f[2];
    if(press(t1) > 0) {
        string tmp = "";
        tmp += f[0];
        if(press(tmp) > 0) res = f[0];
        else res = f[1];
    }
    else {
        string tmp = "";
        tmp += f[2];
        if(press(tmp) > 0) res = f[2];
        else res = f[3];
    }


    char ban = res[0];
    vector<char> choose;
    for(int i = 0; i < 4; i++) if(f[i] != ban) choose.pb(f[i]);


    for(int i = 2; i <= n; i++) {
        if(i != n) {
            string tmp = "";
            tmp += res + choose[0] + choose[0];
            tmp += res + choose[0] + choose[1];
            tmp += res + choose[0] + choose[2];
            tmp += res + choose[1];

            int x = press(tmp);
            if(x == sz(res)) res += choose[2];
            else if(x == sz(res) + 1) res += choose[1];
            else res += choose[0];
        }
        else {
            for(int j = 0; j < 2; j++) {
                string tmp = res + choose[j];
                if(press(tmp) > sz(res)) {
                    res += choose[j];
                    break;
                }
            }
            if(sz(res) != n) res += choose[2];
        }
    }

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