# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
714707 | bin9638 | 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;
#define N 510
#define ll long long
#define ii pair<int,int>
#define fs first
#define sc second
#define pb push_back
#define iii pair<int,ii>
#ifdef SKY
string s;
int press(string p)
{
//cout<<s<<" "<<p<<endl;
for(int sz=s.size();sz>=1;sz--)
{
for(int i=0;i+sz-1<p.size();i++)
if(s.substr(0,sz)==p.substr(i,sz))
return sz;
}
return 0;
}
#endif
vector<char>kt;
string guess_sequence(int n)
{
char start;
if(press("XY")==0)
{
if(press("A")==0)
start='B';
else start='A';
}else
{
if(press("X")==0)
start='Y';
else start='X';
}
vector<char>cc={'A','B','X','Y'};
for(auto ch:cc)
if(ch!=start)
kt.pb(ch);
string kq="";
kq.pb(start);
for(int i=1;i<n-1;i++)
{
string ask="";
ask+=kq+kt[0];
ask+=kq+kt[1]+kt[0]+kq+kt[1]+kt[1]+kq+kt[1]+kt[2];
int val=press(ask);
if(val==kq.size())
{
kq.pb(kt[2]);
continue;
}
if(val==kq.size()+1)
{
kq.pb(kt[0]);
continue;
}
if(val==kq.size()+2)
{
kq.pb(kt[1]);
continue;
}
}
if(press(kq+kt[0]+kq+kt[1])==kq.size()+1)
{
if(press(kq+kt[0])==kq.size()+1)
kq.pb(kt[0]);
else kq.pb(kt[1]);
}else
kq.pb(kt[2]);
return kq;
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
cin>>s;
cout<<guess_sequence(s.size());
return 0;
}
#endif // SKY