# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
534537 | almothana05 | 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 "combo.h"
using namespace std;
string cmp , erg = "" ;
int numm = 0 , nummer = 0;
char buch;
string guess_sequence(int menge) {
string p = "";
p = "AB";
numm = press(p);
if(numm == 2){
erg = p;
buch = 'A';
}
else if(numm > 0){
p = 'A';
numm = press(p);
if(numm == 1){
erg += 'A';
buch = 'A';
}
else{
erg += 'B';
buch = 'B';
}
}
else{
p = 'X';
numm = press(p);
if(numm == 1){
erg += 'X';
buch = 'X';
}
else{
erg += 'Y';
buch = 'Y';
}
}
if(buch == 'A'){
cmp = "BXY";
}
else if(buch == 'B'){
cmp = "AXY";
}
else if(buch == 'X'){
cmp = "ABY";
}
else{
cmp = "ABX";
}
int rechner = 0;
while(erg.size() < menge - 1 ){
p = "";
erg += cmp[0];
p += erg;
erg.pop_back();
erg += cmp[1];
erg += cmp[0];
p += erg;
erg.pop_back();
erg += cmp[1];
p += erg;
erg.pop_back();
erg += cmp[2];
p += erg;
erg.pop_back();
erg.pop_back();
numm = press(p);
if(numm == erg.size()){
erg += cmp[2];
}
else if(numm - 1 == erg.size()){
erg += cmp[0];
}
else{
erg += cmp[1];
}
}
p = "";
if(erg.size() < menge){
erg += cmp[0];
numm = press(erg);
if(numm == erg.size()){
return erg;
}
erg.pop_back();
erg += cmp[1];
numm = press(erg);
if(numm == erg.size()){
return erg;
}
erg.pop_back();
erg += cmp[2];
numm = press(erg);
if(numm == erg.size()){
return erg;
}
erg.pop_back();
}
assert(erg.size() == menge);
return erg;
}