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"bits/stdc++.h"
#include "combo.h"
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
std::string guess_sequence(int N) {
string s = "";
int len = 1;
string pos = "ABXY";
if (press("AB")) {
if (press("A")) s = "A";
else s = "B";
} else {
if (press("X")) s = "X";
else s = "Y";
}
pos.erase(find(pos.begin(), pos.end(),s[0]));
while (len < N) {
// cerr << s << endl;
if (N - len == 1) {
if (press(s + pos[0] + s + pos[1]) - len) {
if (press(s + pos[0]) - len) s += pos[0];
else s += pos[1];
} else {
s += pos[2];
}
len++;
} else {
int Q = press(s + pos[0] + pos[0] + s + pos[0] + pos[1] + s + pos[1] + pos[1]);
if (Q == len+0) {
s += pos[2];
len++;
} else if (Q == len+1) {
Q = press(s + pos[1] + pos[0]);
if (Q == len+2) {
s += pos[1];
s += pos[0];
len += 2;
} else if (Q == len+1) {
s += pos[1];
s += pos[2];
len += 2;
} else {
s += pos[0];
s += pos[2];
len += 2;
}
} else {
Q = press(s + pos[0] + pos[0]);
if (Q == len+2) {
s += pos[0];
s += pos[0];
len += 2;
} else if (Q == len+1) {
s += pos[0];
s += pos[1];
len += 2;
} else {
s += pos[1];
s += pos[1];
len += 2;
}
}
}
}
// cerr << s << endl;
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |