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 <cassert>
#include "combo.h"
using namespace std;
string L = "ABXY";
string guess_sequence(int N) {
string ans = "";
for (int i = 0; i < 4; i++) {
string t = "";
t += L[i];
if (i == 3 || press(t) == 1) {
swap(L[i], L[0]);
break;
}
}
ans += L[0];
for (int i = 0; i < N - 2; i++) {
int cl = 1 + i;
string t = "";
t += ans + L[1] + L[1];
t += ans + L[1] + L[2];
t += ans + L[1] + L[3];
t += ans + L[2];
// assert(((int) t.size()) <= 4 * N);
int c = press(t);
if (c == cl + 2) {
ans += L[1];
} else if (c == cl + 1) {
ans += L[2];
} else {
ans += L[3];
}
}
// assert(((int) ans.size()) == N - 1);
if (((int) ans.size()) == N - 1) {
for (int i = 1; i < 4; i++) {
string t = ans;
t += L[i];
if (i == 3 || press(t) == N) {
ans += L[i];
break;
}
}
}
// assert(((int) ans.size()) == N);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |