#include "combo.h"
std::string guess_sequence(int N) {
std::string ans;
//std::string s;
std::string alp = "ABXY";
int coin;
coin = press("AB");
if(coin) {
coin = press("A");
if (coin) ans = "A";
else ans = "B";
} else {
coin = press("X");
if (coin) ans = "X";
else ans = "Y";
}
std::string temp;
for (auto i: alp) if (i != ans[0]) temp += i;
//int tindex = 0; //012
while(ans.size() < N) {
int now = ans.size();
char last = ans.back();
for (auto i: temp) {
if (i == last) continue;
std::string s = ans;
for (int c = 0; c < N;c++) s += (char)i;
//std::cout << s << "\n";
coin = press(s);
if (coin > now) {
for (int k = now + 1; k <= coin; k++) {
ans += i;
}
break;
}
}
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |