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>
std::string guess_sequence(int N) {
using namespace std;
auto guess = [&](string p) {
return press(p);
};
vector<string> ch = {"A", "B", "X", "Y"};
string fst = "?";
for (int i = 0; i < 3; i++) {
string p = ch[i];
int coins = press(p);
if (coins == 1) {
fst = ch[i];
break;
}
}
if (fst == "?") {
fst = "Y";
}
vector<string> nch = {};
for (auto x : ch) {
if (x != fst) nch.push_back(x);
}
string ans = fst;
for (int i = 1; i < N; i++) {
bool found = false;
for (int j = 0; j < 2; j++) {
string tmp = ans + nch[j];
int coins = guess(tmp);
if (coins == i + 1) {
found = true;
ans += nch[j];
break;
}
}
if (!found) {
ans += nch[2];
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |