# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
401515 | tredsused70 | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
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>
using namespace std;
/*string god;
int cnt=0;
int press(string s)
{
int ans=0,row=0,pos;
for(int i=0;i<s.size();i++)
{
pos=i;
while(row<god.size() && pos<s.size() && god[row]==s[pos])
{
row++;
pos++;
}
ans=max(ans,row);
row=0;
}
cnt++;
cout << "press " << s << " " << ans << "\n";
return ans;
}*/
int press(string p);
string guess_sequence(int n)
{
string ans,help;
char st;
if(press("AX"))
{
if(press("A")==1)
ans="A";
else
ans="X";
}
else
{
if(press("B")==1)
ans="B";
else
ans="Y";
}
st=ans[0];
for(int i=1;i<n;i++)
{
help=ans+"A";
help+=ans+"B";
if(press(help)==i+1)
{
if(press(ans+"A")==i+1)
ans+="A";
else
ans+="B";
}
else
{
if(press(ans+"X")==i+1)
ans+="X";
else
ans+="Y";
}
help.clear();
}
return ans;
}
int main()
{
int n;
//cin >> god;
cin >> n;
cout << guess_sequence(n);
cout << "\n";
//cout << cnt << "\n";
return 0;
}