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;
char ar[]="ABXY";
string guess_sequence(int N) {
string p = "";
int i;
p="AB";
if (press(p)) {
p="A";
if (press(p)) p="A";
else p="B";
}
else {
p="X";
if (press(p)) p="X";
else p="Y";
}
for (i=0; i<4; i++) if (p[0]==ar[i]) {
for (i=i+1; i<4; i++) ar[i-1]=ar[i];
break;
}
if (N==1) return p;
string q;
for (i=1; i<N-1; i++) {
q="";
q+=p; q+=ar[0]; q+=ar[0];
q+=p; q+=ar[0]; q+=ar[1];
q+=p; q+=ar[0]; q+=ar[2];
q+=p; q+=ar[1];
int ret=press(q);
if (ret==i+2) p+=ar[0];
else if (ret==i+1) p+=ar[1];
else p+=ar[2];
}
p+=ar[0];
if (press(p)==N) return p;
p[N-1]=ar[1];
if (press(p)==N) return p;
p[N-1]=ar[2]; return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |