# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017074 | eldorbek_008 | 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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
#define len(x) (int)(x).size()
std::string guess_sequence(int N) {
string a;
int x = press("AB");
if (x > 0) {
x = press("B");
if (x > 0) {
a = "B";
} else {
a = "A";
}
} else {
x = press("Y");
if (x > 0) {
a = "Y";
} else {
a = "X";
}
}
string r = "";
string l = "ABXY";
for (int i = 0; i < 4; i++) {
if (l[i] != a[0]) {
r += l[i];
}
}
for (int i = 0; i < N - 2; i++) {
string cur = a + r[1] + a + r[0] + r[1] + a + r[0] + r[0] + a + r[0] + r[2];
int y = press(cur);
if (y == len(a) + 1) {
a += r[1]; // only a + r[1] can make len(a) + 1
} else if (y == len(a) + 2) {
a += r[0]; // next char must be r[0]
} else {
a += r[2]; // last choice
}
}
string last = a + r[0] + a + r[1];
x = guess(last);
if (x == len(a) + 1) {
last = a + r[0];
x = guess(last);
if (x == len(a)) {
a += r[1];
} else {
a += r[0];
}
} else {
a += r[2];
}
return a;
}