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 <bits/stdc++.h>
#include "combo.h"
using namespace std;
// int press(string s)
string guess_sequence(int N){
string ans;
int x = 0;
if(press(string(N * 2, 'A') + string(N * 2, 'B'))){
if(press(string(N * 4, 'B')) == 1) x = 1;
}
else{
if(press(string(N * 4, 'X')) == 1) x = 2;
else x = 3;
}
if(x == 0){
ans = "A";
while((int)ans.size() < N - 1){
string f = ans + "B" + ans + "XB" + ans + "XX" + ans + "XY";
// cout << f << endl;
int res = press(f);
if(res == (int)ans.size()){
ans += "Y";
}
else if(res == (int)ans.size() + 1){
ans += "B";
}
else{
ans += "X";
}
}
if(press(ans + "X") == N) ans += "X";
else if(press(ans + "Y") == N) ans += "Y";
else ans += "B";
}
else if(x == 1){
// cout << "HERE" << endl;
ans = "B";
while((int)ans.size() < N - 1){
string f = ans + "A" + ans + "XA" + ans + "XX" + ans + "XY";
int res = press(f);
if(res == (int)ans.size()){
ans += "Y";
}
else if(res == (int)ans.size() + 1){
ans += "A";
}
else{
ans += "X";
}
}
// cout << ans << endl;
if(press(ans + "X") == N) ans += "X";
else if(press(ans + "Y") == N) ans += "Y";
else ans += "A";
}
else if(x == 2){
ans = "X";
while((int)ans.size() < N - 1){
string f = ans + "B" + ans + "AB" + ans + "AA" + ans + "AY";
int res = press(f);
if(res == (int)ans.size()){
ans += "Y";
}
else if(res == (int)ans.size() + 1){
ans += "B";
}
else{
ans += "A";
}
}
if(press(ans + "A") == N) ans += "A";
else if(press(ans + "Y") == N) ans += "Y";
else ans += "B";
}
else{
ans = "Y";
while((int)ans.size() < N - 1){
string f = ans + "B" + ans + "XB" + ans + "XX" + ans + "XA";
int res = press(f);
if(res == (int)ans.size()){
ans += "A";
}
else if(res == (int)ans.size() + 1){
ans += "B";
}
else{
ans += "X";
}
}
if(press(ans + "X") == N) ans += "X";
else if(press(ans + "A") == N) ans += "A";
else ans += "B";
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |