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>
#include <iostream>
/*
Saa Sab Sba
0 -> {
S = Sc
}
1 -> {
A: Sac Sbb Sbc
Sbb
0 -> S = Sac
1 -> S = Sbc
2 -> S = Sbb
}
2 -> {
A: Saa Sab Sba
Saa
0 -> S = Sba
1 -> S = Sab
2 -> S = Saa
}
*/
std::string guess_sequence(int N) {
char a, b, c;
std::string S;
if(press("AB") != 0) {
if(press("A") != 0) {
a = 'B';
b = 'X';
c = 'Y';
S = "A";
} else {
a = 'A';
b = 'X';
c = 'Y';
S = "B";
}
} else {
if(press("X") != 0) {
a = 'A';
b = 'B';
c = 'Y';
S = "X";
} else {
a = 'A';
b = 'B';
c = 'X';
S = "Y";
}
}
while((int)S.size() < N - 1) {
int r = press(S+a+a + S+a+b + S+b+a);
if(r == (int)S.size()) {
S = S + c;
} else if(r == (int)S.size() + 1) {
// Sac Sbb Sbc
int r2 = press(S+b+b);
if(r2 == (int)S.size()) {
S = S + a + c;
} else if(r2 == (int)S.size() + 1) {
S = S + b + c;
} else {
S = S + b + b;
}
} else if(r == (int)S.size() + 2) {
// Saa Sab Sba
int r2 = press(S+a+a);
if(r2 == (int)S.size()) {
S = S + b + a;
} else if(r2 == (int)S.size() + 1) {
S = S + a + b;
} else {
S = S + a + a;
}
}
}
if((int)S.size() == N - 1) {
if(press(S+a + S+b) == (int)S.size() + 1) {
if(press(S+a) == (int)S.size() + 1) {
S += a;
} else {
S += b;
}
} else {
S += c;
}
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |