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;
string guess_sequence(int N) {
const string valid = "ABXY";
char fir;
string ans = "";
if (press("AB")) {
if (press("AX")) fir = 'A';
else fir = 'B';
} else {
if (press("AX")) fir = 'X';
else fir = 'Y';
}
ans += fir;
if (N == 1) return ans;
for (int i = 1; i < N - 1; i++) {
string req = "";
int cnt = 0;
for (int j = 0; j < 4; j++) {
if (valid[j] == fir) continue;
cnt++;
if (cnt == 1) continue;
else if (cnt == 2) {
req += ans + valid[j];
} else {
for (int k = 0; k < 4; k++) {
if (valid[k] == fir) continue;
req += ans + valid[j] + valid[k];
}
}
}
int res = press(req) - i;
for (int j = 0; j < 4; j++) {
if (valid[j] == fir) continue;
if (res == 0) {
ans += valid[j];
break;
}
res--;
}
}
int cnt = 0;
for (int i = 0; i < 4; i++) {
if (valid[i] == fir) continue;
string tar = ans + valid[i];
if (cnt == 2) return tar;
if (press(tar) == N) return tar;
cnt++;
}
return "";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |