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>
std::string guess_sequence(int n) {
std::vector <char> KEYS = {'A', 'B', 'X', 'Y'};
std::string ans = press("AB") ? press("A") ? "A" : "B" : press("X") ? "X" : "Y";
KEYS.erase(std::find(KEYS.begin(), KEYS.end(), ans[0]));
while ((int) ans.size() <= n - 2) {
int t = press(ans + KEYS[0] + KEYS[0] + ans + KEYS[0] + KEYS[1] + ans + KEYS[1] + KEYS[0]);
if (t == (int) ans.size())
ans = ans + KEYS[2];
if (t == (int) ans.size() + 1)
ans = ans + (press(ans + KEYS[0]) == (int) ans.size() ? KEYS[1] : KEYS[0]) + KEYS[2];
if (t == (int) ans.size() + 2) {
int tt = press(ans + KEYS[0] + KEYS[0]);
if (tt == (int) ans.size())
ans = ans + KEYS[1] + KEYS[0];
if (tt == (int) ans.size() + 1)
ans = ans + KEYS[0] + KEYS[1];
if (tt == (int) ans.size() + 2)
ans = ans + KEYS[0] + KEYS[0];
}
}
while ((int) ans.size() != n) {
if (press(ans + KEYS[0]) != (int) ans.size()) {
ans = ans + KEYS[0];
break;
}
if (press(ans + KEYS[1]) != (int) ans.size()) {
ans = ans + KEYS[1];
break;
}
ans = ans + KEYS[2];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |