제출 #744634

#제출 시각아이디문제언어결과실행 시간메모리
744634Rafi22Combo (IOI18_combo)C++14
100 / 100
32 ms608 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define ll long long
ll mod=1000000007;
int inf=1000000007;
ll infl=1000000000000000007;

/*int press(string x)
{
    cout<<"? "<<x<<endl;
    int k;
    cin>>k;
    return k;
}*/

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>V1={'A','B','X','Y'},V;
    for(auto x:V1) if(x!=ans[0]) V.pb(x);
    for(int i=2;i<=n-1;)
    {
        int k=press(ans+V[0]+V[0]+ans+V[0]+V[1]+ans+V[1]+V[0]);
        if(k==i-1)
        {
            ans+=V[2];
            i++;
        }
        else if(k==i)
        {
            k=press(ans+V[1]+V[1]);
            if(k==i-1) ans=ans+V[0]+V[2];
            else if(k==i) ans=ans+V[1]+V[2];
            else ans=ans+V[1]+V[1];
            i+=2;
        }
        else
        {
            k=press(ans+V[0]+V[0]);
            if(k==i-1) ans=ans+V[1]+V[0];
            else if(k==i)ans=ans+V[0]+V[1];
            else ans=ans+V[0]+V[0];
            i+=2;
        }
    }
    if(sz(ans)!=n)
    {
        if(press(ans+V[0])==n) ans+=V[0];
        else if(press(ans+V[1])==n) ans+=V[1];
        else ans+=V[2];
    }
    return ans;
}

/*int main()
{
    cout<<guess_sequence(5)<<endl;
    return 0;
}*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...