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"
std::string guess_sequence(int N) {
std::string t = "";
char first, a[5];
//first letter
int p = press("AB"), k = 0, sz = 0;
if(p == 2){
t += "AB"; first = 'A'; sz = 2;
}else
if(p == 1){
int x = press("A");
if(x)t += "A";else t += "B";
sz = 1; first = t[0];
}else{
int x = press("X");
if(x)t += "X";else t += "Y";
sz = 1; first = t[0];
}
if (first != 'A') a[k++] = 'A';
if (first != 'B') a[k++] = 'B';
if (first != 'X') a[k++] = 'X';
if (first != 'Y') a[k++] = 'Y';
//middle
while (sz <= N - 2){
std::string temp = t + a[0] + a[0];
temp += t + a[0] + a[1];
temp += t + a[0] + a[2];
temp += t + a[1];
p = press(temp);
if (p - sz == 0) t += a[2];
else if (p - sz == 1) t += a[1];
else t += a[0];
sz++;
}
//end
//check end
if (sz == N - 1){
p = press(t + "A" + t + "B");
if (p == N){
p = press(t + "A");
if (p == N) t += "A";
else t += "B";
}else{
p = press(t + "X");
if (p == N) t += "X";
else t += "Y";
}
}
return t;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |