This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |