# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
427654 | daanolav | 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 <string>
using namespace std;
string characters[4];
std::string guess_sequence(int N) {
characters[0] = "A";
characters[1] = "B";
characters[2] = "X";
characters[3] = "Y";
string start = "";
int res = press("AB");
if(res >= 1) {
if(res == 2) {
start = "AB";
} else {
res = press("AX");
if(res == 0) {
start = "B";
} else if(res == 1) {
start = "A";
} else {
start = "AX";
}
}
} else {
res = press("XA");
if(res == 0) {
start = "Y";
} else if(res == 1) {
start = "X";
} else {
start = "XA";
}
}
cerr << start << endl;
string first = "" + start.at(0);
string notFirst[3];
int i = 0;
for(string c : characters) {
if(first == c) {
continue;
}
notFirst[i] = c;
++i;
}
while(start.size() != N) {
res = press(start + notFirst[0] + start + notFirst[1] + notFirst[0]);
if(res == start.size()) {
start = start + notFirst[2];
} else if(res == start.size() + 2) {
start = start + notFirst[1] + notFirst[0];
} else {
res = press(start + notFirst[0] + notFirst[0]);
if(res == start.size()) {
start = start + notFirst[1];
} else if(res == start.size() + 2) {
start = start + notFirst[0] + notFirst[0];
} else {
start = start + notFirst[0];
}
}
}
return "";
}