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;
typedef long long ll;
string button[]={"A", "B", "X", "Y"};
string guess_sequence(int n) {
string s="";
int p=press("AB");
if(p) s=(press("A")?"A":"B");
else s=(press("X")?"X":"Y");
string start=s;
string first=(s[0]=='A'?"B":"A"), second=(s[0]=='X'?"Y":"X"), third;
if(n>1) {
for(int i=0; i<4; i++) if(!(button[i]==first || button[i]==second || button[i]==s)) third=button[i];
for(int i=0; i<n-2; i++) {
string q="";
for(int j=0; j<4; j++) if(button[j]!=start) q+=s+first+button[j];
q+=s+second;
int p=press(q);
if(p==(int)s.size()) s+=third;
else if(p==(int)s.size()+1) s+=second;
else s+=first;
}
string q=s+first+s+second;
p=press(q);
if(p==(int)s.size()) s+=third;
else {
q=s+first;
if(press(q)==(int)s.size()) s+=second;
else s+=first;
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |