#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'
// int press(string ans)
// {
// cout << ans << endl << flush;
// int x;
// cin >> x;
// return x;
// }
string guess_sequence(int N)
{
string ans="";
string c="ABXY";
if(press("AB"))
{
if(press("A"))
{
c.erase(c.find('A'), 1);
ans='A';
}
else
{
c.erase(c.find('B'), 1);
ans='B';
}
}
else
{
if(press("X"))
{
c.erase(c.find('X'), 1);
ans='X';
}
else
{
c.erase(c.find('Y'), 1);
ans='Y';
}
}
if(N==1) return ans;
for(int i = 1;i < N-1;i++)
{
string ask=ans+c[0]+c[0]+ans+c[0]+c[1]+ans+c[0]+c[2]+ans+c[1];
int len=press(ask);
if(len==i) ans+=c[2];
else if(len==i+1)ans+=c[1];
else ans+=c[0];
}
if(press(ans+"AB")==N)
{
if(press(ans+"A")==N)
{
ans+='A';
}
else
{
ans+='B';
}
}
else
{
if(press(ans+"X")==N)
{
ans+='X';
}
else
{
ans+='Y';
}
}
return ans;
}
// int main()
// {
// cout << guess_sequence(3);
// }
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |