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;
std::string guess_sequence(int N) {
std::string p = "AB", S = "", P = "";
string f, s, t;
int coins = press(p);
if(coins){
p = "A"; coins = press(p);
if(coins) { S = "A", f = "B", s = "X", t = "Y"; }
else { f = "A", S = "B", s = "X", t = "Y"; }
}
else{
p = "X"; coins = press(p);
if(coins) { f = "A", s = "B", S = "X", t = "Y"; }
else { f = "A", s = "B", t = "X", S = "Y"; }
}
int i;
for (i = 1; i < N - 1; ++i) {
P = "";
P = (S + f + f) + (S + s + f) + (S + s + s);
coins = press(P);
if(coins == i) { S += t; continue; }
else if(coins == i+1){
P = S + f + s;
coins = press(P);
if(coins == i) S += s + t;
else if(coins == i+1) S += f + t;
else S += f + s;
}
else{
P = S + s + f;
coins = press(P);
if(coins == i) S += s + t;
else if(coins == i+1) S += s + s;
else S += f + f;
}
++i;
}
if(i == N - 1){
P = S + f;
coins = press(P);
if(coins == N) S += f;
else{
P = S + s;
coins = press(P);
if(coins == N) S += s;
else S += t;
}
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |