제출 #750134

#제출 시각아이디문제언어결과실행 시간메모리
750134anhduc2701Combo (IOI18_combo)C++17
100 / 100
38 ms572 KiB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
#define all(x) x.begin(), x.end()
#define len(x) ll(x.size())
#define eb emplace_back
#define PI acos(-1.0)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define MIN(v) *min_element(all(v))
#define MAX(v) *max_element(all(v))
#define BIT(x, i) (1 & ((x) >> (i)))
#define Mpress(x) (1LL << (x))
#define tpress "tnc"
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
const int mo = 998244353;
using pi = pair<ll, ll>;
using vi = vector<ll>;
using pii = pair<pair<ll, ll>, ll>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
string x[] = {"A", "B", "X", "Y"};
int N;
string ans;
/*
int press(string s){
    cout<<s<<endl;
    int k;
    cin>>k;
    return k;
}
*/
string guess_sequence(int n)
{
    string d;
    int k = press("AB");
    if (k > 0)
    {
        int d = press("A");
        if (d == 1)
        {
            ans += "A";
        }
        else
        {
            ans += "B";
            swap(x[0], x[1]);
        }
    }
    else
    {
        int d = press("X");
        if (d == 1)
        {
            ans += "X";
            swap(x[0], x[2]);
        }
        else
        {
            ans += "Y";
            swap(x[0], x[3]);
        }
    }
    k = 1;
    while (k + 2 <= n)
    {
        string s = ans;
        s += x[1];
        s += x[1];
        s += ans;
        s += x[1];
        s += x[2];
        s += ans;
        s += x[2];
        s += x[2];
        int p = press(s);
        if (p == k)
        {
            ans += x[3];
            k++;
        }
        else if (p == k + 1)
        {
            s = ans;
            s += x[2];
            s += x[3];
            int d = press(s);
            if (d == k)
            {
                ans += x[1];
                ans += x[3];
                k += 2;
            }
            else if (d == k + 1)
            {
                ans += x[2];
                ans += x[1];
                k += 2;
            }
            else if (d == k + 2)
            {
                ans += x[2];
                ans += x[3];
                k += 2;
            }
        }
        else if (p == k + 2)
        {
            s = ans;
            s += x[1];
            s += x[1];
            int d = press(s);
            if (d == k)
            {
                ans += x[2];
                ans += x[2];
                k += 2;
            }
            else if (d == k+1)
            {
                ans += x[1];
                ans += x[2];
                k += 2;
            }
            else if (d == k+2)
            {
                ans += x[1];
                ans += x[1];
                k += 2;
            }
        }
    }
    if (k < n)
    {
        string s = ans + x[1];
        int d = press(s);
        if (d == n)
        {
            return ans + x[1];
        }
        else
        {
            s = ans + x[2];
            if (press(s) == n)
            {
                return s;
            }
            else
            {
                return ans + x[3];
            }
        }
    }
    return ans;
}
/*
signed main(){
    int n;
    cin>>n;
    cout<<guess_sequence(n);
}
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...