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, tr[5];
//check first
int p = press("AB"), sz = 0, k = 0;
if (!p){
p = press("X");
if (p == 1) t += "X", first = 'X';
else t += "Y", first = 'Y';
sz++;
}
else if (p == 1){
p = press("A");
if (p == 1) t += "A", first = 'A';
else t += "B", first = 'B';
sz++;
}
else t += "AB", sz += 2, first = 'A';
if (first != 'A') tr[k++] = 'A';
if (first != 'B') tr[k++] = 'B';
if (first != 'X') tr[k++] = 'X';
if (first != 'Y') tr[k++] = 'Y';
//check middle
while (sz <= N - 2){
std::string temp = t + tr[0] + tr[0];
temp += t + tr[0] + tr[1];
temp += t + tr[0] + tr[2];
temp += t + tr[1];
p = press(temp);
if (p - sz == 0) t += tr[2];
else if (p - sz == 1) t += tr[1];
else t += tr[0];
sz++;
}
//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... |