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>
using namespace std;
int press(std::string p);
char find_first(){
int q = press("AB");
if(q >= 1){
q = press("A");
if(q)
return 'A';
return 'B';
}
q = press("X");
if(q)
return 'X';
return 'Y';
}
string guess_sequence(int N){
vector<string> c {"A", "B", "X", "Y"};
char f = find_first();
for(int i = 0; i < 4; ++i){
if(c[i][0] == f){
c.erase(c.begin() + i);
break;
}
}
string s = "";
s += f;
if(N == 1)
return s;
vector<string> Q {c[0], c[1] + c[0], c[1] + c[1], c[1] + c[2]};
for(int i = 2; i < N; ++i){
string t = "";
for(int j = 0; j < 4; ++j) t += s + Q[j];
int q = press(t);
if(q == i - 1){
s += c[2];
}else if(q == i){
s += c[0];
}else{
s += c[1];
}
}
int q = press(s + c[0]);
if(q == N){
s += c[0];
}else{
q = press(s + c[1]);
if(q == N){
s += c[1];
}else{
s += c[2];
}
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |