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;
int first = -1;
char X[] = {'A', 'B', 'X', 'Y'};
inline char getChar(int x){
if (x < first) return X[x];
return X[x+1];
}
string guess_sequence(int N) {
string p = "";
int v1 = press("AB");
int v2 = press("AX");
// Determine first letter;
if (v1 >= 1 && v2 >= 1){
p += "A";
first = 0;
}
else{
if (v1 >= 1){
p += "B";
first = 1;
}
else{
if (v2 >= 1){
p += "X";
first = 2;
}
else{
p += "Y";
first = 3;
}
}
}
if (N == 1) return p;
// Determine 2nd, 3rd, ..., N-1th letter
for (int i=0; i<N-2; i++){
string to_guess = "";
for (int j=0; j<3; j++){
to_guess += p;
to_guess += getChar(0);
to_guess += getChar(j);
}
to_guess += p;
to_guess += getChar(1);
int res = press(to_guess);
if (res == i+2) p += getChar(1);
else{
if (res == i+3) p += getChar(0);
else p += getChar(2);
}
}
// Determine last letter
if (press(p+getChar(0))==N) return p + getChar(0);
if (press(p+getChar(1))==N) return p + getChar(1);
return p + getChar(2);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |