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;
#define dbg(x) cerr << #x << ": " << x << endl;
const char chars[] = {'A', 'B', 'X', 'Y'};
int press(string p);
string guess_sequence(int n) {
char first_char;
if (press("AB")) {
if (press("A")) {
first_char = 'A';
} else {
first_char = 'B';
}
} else {
if (press("X")) {
first_char = 'X';
} else {
first_char = 'Y';
}
}
string good;
for (auto c : chars) {
if (c != first_char) good += c;
}
string res = string(1, first_char);
for (int i = 2; i <= n - 1; ++i) {
string t;
t += res + good[0];
t += res + good[1] + good[0];
t += res + good[1] + good[1];
t += res + good[1] + good[2];
int len = press(t);
if (len == i) {
res += good[0];
} else if (len == i + 1) {
res += good[1];
} else {
res += good[2];
}
}
if (press(res + good[0]) == n) {
res += good[0];
} else {
if (press(res + good[1]) == n) {
res += good[1];
} else {
res += good[2];
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |