# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
805744 | AlphaMale06 | 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.
#include <bits/stdc++.h>
#include <combo.h>
using namespace std;
#define pb push_back
int press(string s){
cout << s << '\n';
int x;
cin >> x;
return x;
}
char guess_first(){
int ans = press("AB");
if(ans==0){
ans=press("X");
if(ans==1){
return 'X';
}
return 'Y';
}
else{
ans=press("A");
if(ans==1){
return 'A';
}
return 'B';
}
}
string guess_sequence(int n){
char f = guess_first();
vector<char> nf;
if('A'!=f)nf.pb('A');
if('B'!=f)nf.pb('B');
if('X'!=f)nf.pb('X');
if('Y'!=f)nf.pb('Y');
int gsd=1;
string ans= "";
ans+=f;
if(n==1){
return ans;
}
while(gsd<n-1){
string gs=ans+nf[0]+nf[0]+ans+nf[0]+nf[1]+ans+nf[0]+nf[2]+ans+nf[1]+nf[0];
int kita=press(gs);
if(kita==gsd-1){
ans.pop_back();
ans+=nf[1];
ans+=nf[0];
gsd++;
}
else if(kita==gsd){
gsd++;
ans+=nf[2];
}
else if(kita==gsd+1){
gsd++;
ans+=nf[1];
}
else{
gsd++;
ans+=nf[0];
if(gsd==n-1){
kita=press(ans+nf[0]);
if(kita==gsd){
ans.pop_back();
ans+=nf[1];
kita=press(ans);
if(kita==n){
return ans;
}
else{
ans.pop_back();
return ans+nf[2];
}
}
else if(kita==gsd-1){
ans.pop_back();
return ans+nf[1]+nf[0];
}
else if(kita==gsd+1){
return ans;
}
}
}
}
string gs=ans+nf[0];
if(press(gs)==n){
return gs;
}
else{
gs.pop_back();
gs+=nf[1];
if(press(gs)==n){
return gs;
}
else{
gs.pop_back();
return gs+nf[2];
}
}
}