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 <vector>
using namespace std;
vector<string> chars(3);
vector<string> cur(3);
std::string guess_sequence(int N) {
string ans;
int coin = press("AB");
if(coin == 0) {
coin = press("X");
if(coin == 0) {
ans = "Y";
chars = {"A", "B", "X"};
} else {
ans = "X";
chars = {"A", "B", "Y"};
}
} else {
coin = press("A");
if(coin == 0) {
ans = "B";
chars = {"A", "Y", "X"};
} else {
ans = "A";
chars = {"Y", "B", "X"};
}
}
if(N == 1) return ans;
cur = {ans+chars[0], ans+chars[1], ans+chars[2]};
int sz = 2;
while(sz < N) {
coin = press(cur[0] + chars[0] + cur[1] + chars[1] + cur[0] + chars[1]);
if(coin == sz + 1) {
cur = {cur[0] + chars[0], cur[1] + chars[1], cur[0] + chars[1]};
} else if (coin == sz) {
cur = {cur[0] + chars[2], cur[1] + chars[0], cur[1] + chars[2]};
} else if (coin == sz - 1) {
cur = {cur[2] + chars[0], cur[2] + chars[1], cur[2] + chars[2]};
}
sz++;
}
coin = press(cur[0]);
if(coin == sz) {
ans = cur[0];
} else {
coin = press(cur[1]);
if(coin == sz) {
ans = cur[1];
} else {
ans = cur[2];
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |