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 <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include "combo.h"
using namespace std;
string guess_sequence(int N) {
char x, y, z, w;
if (press("AB")) {
z = 'X';
w = 'Y';
if (press("A")) {
x = 'A';
y = 'B';
} else {
x = 'B';
y = 'A';
}
} else {
z = 'A';
w = 'B';
if (press("X")) {
x = 'X';
y = 'Y';
} else {
x = 'Y';
y = 'X';
}
}
string ret = "";
ret += x;
for (int i = 1, tmp; i < N - 1; i++) {
string query = ret + y + ret + z + y + ret + z + z + ret + z + w;
tmp = press(query);
if (tmp == (int) ret.size() + 2) {
ret += z;
} else if (tmp == (int) ret.size() + 1) {
ret += y;
} else {
ret += w;
}
}
if (press(ret + y) == N) {
ret += y;
} else if (press(ret + z) == N) {
ret += z;
} else {
ret += w;
}
cout << ret << "\n";
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |