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<bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
string p;
//p = "";
//p+="AB";
//int coins = press(p);
if(press("AB")==0){
if(press("X")==0){
//first = Y
p = "Y";
if(N==1)return p;
for(int i=1;i<=N-2;i++){
int ans = press(p+"A"+p+"BA"+p+"BB"+p+"BX");
if(ans==i){
p+='X';
}
else if(ans==i+1){
p+='A';
}
else{
p+='B';
}
}
if(press(p+'A')==N){
p+='A';
}
else if(press(p+'B')==N){
p+='B';
}
else{
p+='X';
}
}
else{
//first = x
p = "X";
if(N==1)return p;
for(int i=1;i<=N-2;i++){
int ans = press(p+"A"+p+"BA"+p+"BB"+p+"BY");
if(ans==i){
p+='Y';
}
else if(ans==i+1){
p+='A';
}
else{
p+='B';
}
}
if(press(p+'A')==N){
p+='A';
}
else if(press(p+'B')==N){
p+='B';
}
else{
p+='Y';
}
}
}
else{
if(press("A")==0){
//first = B
p = "B";
if(N==1)return p;
for(int i=1;i<=N-2;i++){
int ans = press(p+"A"+p+"YA"+p+"YY"+p+"YX");
if(ans==i){
p+='X';
}
else if(ans==i+1){
p+='A';
}
else{
p+='Y';
}
}
if(press(p+'A')==N){
p+='A';
}
else if(press(p+'Y')==N){
p+='Y';
}
else{
p+='X';
}
}
else{
//first = A
p = "A";
if(N==1)return p;
for(int i=1;i<=N-2;i++){
int ans = press(p+"Y"+p+"BY"+p+"BB"+p+"BX");
if(ans==i){
p+='X';
}
else if(ans==i+1){
p+='Y';
}
else{
p+='B';
}
}
if(press(p+'Y')==N){
p+='Y';
}
else if(press(p+'B')==N){
p+='B';
}
else{
p+='X';
}
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |