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) {
string ans = "";
vector<string> ask;
if (press("AB") >= 1) {
if (press("A")) {
ans += "A";
ask = {"B", "X", "Y"};
} else {
ans += "B";
ask = {"A", "X", "Y"};
}
} else {
if (press("X")) {
ans += "X";
ask = {"A", "B", "Y"};
} else {
ans += "Y";
ask = {"A", "B", "X"};
}
}
if (N == 1) return ans;
for (int i = 2; i <= N - 1; i++) {
string x = ans + ask[0];
string tp = "";
for (int j = 0; j < 3; j++) {
tp += x + ask[j];
}
tp += ans + ask[1];
int ret = press(tp);
if (ret == i + 1) ans += ask[0];
else if (ret == i) ans += ask[1];
else if (ret == i - 1) ans += ask[2];
}
if (press(ans + ask[0]) == N) ans += ask[0];
else if (press(ans + ask[1]) == N) ans += ask[1];
else ans += ask[2];
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |