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"
using namespace std;
string guess_sequence(int N) {
string p = "AB";
int coins = press(p);
string cur = "";
char c[3];
if(coins == 0) {
p = "X";
coins = press(p);
if(coins == 0) {cur = "Y"; c[0] = 'A'; c[1] = 'B'; c[2] = 'X';}
else {cur == "X"; c[0] = 'A'; c[1] = 'B'; c[2] = 'Y';}
}
else {
p = "A";
coins = press(p);
if(coins == 0) {cur = "B"; c[0] = 'A'; c[1] = 'X'; c[2] = 'Y';}
else {cur = "A"; c[0] = 'B'; c[1] = 'X'; c[2] = 'Y';}
}
if(N == 1) return cur;
string S;
for(int i = 1; i <= N-2; i++) {
S = (cur + c[0]) + (cur + c[1] + c[0]) + (cur + c[1] + c[1]) + (cur + c[1] + c[2]);
coins = press(S);
if(coins == i) {cur += c[2];}
else if(coins == (i+1)) {cur += c[0];}
else {cur += c[1];}
}
S = (cur + c[0]) + (cur + c[1]);
coins = press(S);
if(coins < N) {return (cur + c[2]);}
S = cur + c[0];
coins = press(S);
if(coins < N) {return (cur + c[1]);}
return (cur + c[0]);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |