# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007221 | makanhulia | 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>
#include "combo.h"
using namespace std;
string guess_sequence(int n){
string s="";
int tmp=press("AB");
if(tmp>=1){
tmp=press('A');
if(tmp==1) s+='A';
else s+='B';
} else {
tmp=press('X');
if(tmp==1) s+='X';
else s+='Y';
}
while(s.length()<n-1){
if(s[0]=='A'){
tmp=press(s+'B'+s+"XX"+s+"XY"+s+"XB");
if(tmp==s.length()+1){
s+='B';
} else if(tmp==s.length()+2){
s+='X';
} else {
s+='Y';
}
}
if(s[0]=='B'){
tmp=press(s+'A'+s+"XX"+s+"XY"+s+"XA");
if(tmp==s.length()+1){
s+='A';
} else if(tmp==s.length()+2){
s+='X';
} else {
s+='Y';
}
}
if(s[0]=='X'){
tmp=press(s+'B'+s+"AA"+s+"AY"+s+"AB");
if(tmp==s.length()+1){
s+='B';
} else if(tmp==s.length()+2){
s+='A';
} else {
s+='B';
}
}
if(s[0]=='Y'){
tmp=press(s+'B'+s+"AA"+s+"AX"+s+"AB");
if(tmp==s.length()+1){
s+='B';
} else if(tmp==s.length()+2){
s+='A';
} else {
s+='X';
}
}
}
if(n>=2){
tmp=press(s+"A"+s+"B");
if(tmp>=n){
tmp=press(s+"A");
if(tmp==n) s+="A";
else s+="B";
} else {
tmp=press(s+"X");
if(tmp==n) s+="X";
else s+="Y";
}
}
return s;
}