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) {
char que[3];
string ret = "";
if (press("AB")) {
que[0] = 'X';
que[1] = 'Y';
if (press("A")) {
que[2] = 'B';
ret = "A";
}
else {
que[2] = 'A';
ret = "B";
}
}
else {
que[0] = 'A';
que[1] = 'B';
if (press("X")) {
que[2] = 'Y';
ret = "X";
}
else {
que[2] = 'X';
ret = "Y";
}
}
// cerr << "S " << ret << " " << que[0] << " " << que[1] << " " << que[2] << endl;
for (int i = 0; i < N - 2; ++i) {
string query = ret + que[0] + que[0] + ret + que[0] + que[1] + ret + que[0] + que[2] + ret + que[1];
// cerr << "T " << query << " " << query.size() << endl;
int res = press(query);
int s = (int)(ret.size());
if (res == s) ret += que[2];
else if (res == s + 1) ret += que[1];
else ret += que[0];
// cerr << "N " << ret << endl;
}
if (press(ret + que[0]) == N) ret += que[0];
else if (press(ret + que[1]) == N) ret += que[1];
else ret += que[2];
// cerr << ret << endl;
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |