# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
223713 | bharat2002 | Combo (IOI18_combo) | C++14 | 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.
/*input
*/
#include "combo.h"
using namespace std;
//Trace prints the name of the variable and the value.
/*int press(string st)
{
cout<<st<<":";int ret;cin>>ret;return ret;
}*/
void fl();
string ans;char fc;
string guess_sequence(int n)
{
ans="";char arr[5]={'A', 'B', 'X', 'Y'};
fl();
char c1='0', c2='0', c3='0';
for(int j=0;j<4;j++)
{
if(arr[j]==fc) continue;
if(c1=='0') c1=arr[j];
else if(c2=='0') c2=arr[j];
else c3=arr[j];
}
for(int i=2;i<n;i++)
{
string temp=ans;temp+=c1;temp+=ans;temp+=c2;temp+=c1;temp+=ans;temp+=c2;temp+=c2;temp+=ans;temp+=c2;temp+=c3;
assert(temp.size()<=4*n);
int ct=press(temp);
if(ct<i) ans+=c3;
else if(ct==i) ans+=c1;
else ans+=c2;
}
fl();
return ans;
}
void fl()
{
string temp=ans;
temp+="AB";assert(temp.size()<=4*n);
int ct=press(temp);
ct-=ans.size();
if(ct>0)
{
temp.pop_back();assert(temp.size()<=4*n);
ct=press(temp);
ct-=ans.size();
if(ct>0)
{
fc='A';
ans+="A";
}
else
{
ans+="B";fc='B';
}
}
else
{
temp.pop_back();temp.pop_back();temp+="X";assert(temp.size()<=4*n);
ct=press(temp);ct-=ans.size();
if(ct>0)
{
ans+="X";fc='X';
}
else
{
ans+="Y";fc='Y';
}
}
}
/*signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
// guess_sequence(5);
// cout<<"Answer:"<<ans;
}*/