# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863105 | maks007 | 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"
#include "bits/stdc++.h"
#include "grader.cpp"
using namespace std;
string guess_sequence(int n) {
string str = "", abxy, forPress;
if(press("AB")) {
if(press("A")) {
str = "A";
abxy = "BXY";
}else {
str = "B";
abxy = "AXY";
}
}else {
if(press("X")) {
str = "X";
abxy = "ABY";
}else {
str = "Y";
abxy = "ABX";
}
}
if(str.size() == n) return str;
while(1) {
if(str.size() == n - 1) break;
forPress = "";
forPress += str + abxy[0];
forPress += str + abxy[1] + abxy[0] + str + abxy[1] + abxy[1] + str + abxy[1] + abxy[2];
int cnt = press(forPress);
if(cnt == str.size() + 1) str += abxy[0];
else if(cnt == str.size() + 2) str += abxy[1];
else str += abxy[2];
}
if(press(str + abxy[0]) == n) str += abxy[0];
else if(press(str + abxy[1]) == n) str += abxy[1];
else str += abxy[2];
return str;
}