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 TRACE(x) cerr << #x << " " << x << endl
#define _ << " " <<
string guess_sequence(int N) {
string ret = "";
int x = press("AB");
if (x == 2) {
ret = "AB";
}
if (x == 1) {
int y = press("A");
if (y) ret = "A"; else ret = "B";
}
if (x == 0) {
int y = press("X");
if (y) ret = "X"; else ret = "Y";
}
string B = "";
for (char c : "ABXY")
if (c != ret[0]) B.push_back(c);
for (int i = ret.size(); i < N - 1; ++i) {
string guess = "";
for (int j = 0; j < 3; ++j) {
guess += ret;
guess.push_back(B[0]);
guess.push_back(B[j]);
}
guess += ret;
guess.push_back(B[1]);
int x = press(guess);
assert(x >= i);
ret.push_back(B[2 - (x - i)]);
}
ret.push_back(B[0]);
if (press(ret) == N) return ret;
ret.pop_back();
ret.push_back(B[1]);
if (press(ret) == N) return ret;
ret.pop_back();
ret.push_back(B[2]);
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |