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;
#define mt make_tuple
int n ;
inline int ps(string s) {
// cout << s << endl;
assert((int)s.size() <= 4*n);
for (auto e : s) assert(e == 'A' || e == 'B' || e == 'X' || e == 'Y');
return press(s);
}
string guess_sequence(int N) {
n = N;
string A = "";
if (ps("AB")) {
if (ps("A"))
A = "A";
else
A = "B";
}
else {
if (ps("X"))
A = "X";
else
A = "Y";
}
//cout << " :: " << A << endl;
string s0 , s1, s2, s3 , s4;
if (A[0] == 'A') {
tie(s0 , s1 , s2 , s3, s4) = mt("BB" , "BX" , "BY" , "X" , "Y");
}
else if (A[0] == 'B') {
tie(s0 , s1 , s2 , s3, s4) = mt("AA" , "AX" , "AY" , "X" , "Y");
}
else if (A[0] == 'X') {
tie(s0 , s1 , s2 , s3, s4) = mt("BB" , "BA" , "BY" , "A" , "Y");
}
else {
tie(s0 , s1 , s2 , s3, s4) = mt("BB" , "BX" , "BA" , "X" , "A");
}
while ((int)A.size() <= N - 2) {
int res = ps(A + s0 + A + s1 + A + s2 + A + s3);
res -= A.size();
if (res == 0) A += s4;
else if (res == 1) A += s3;
else A.push_back(s0[0]);
// cout << A << endl;
}
if ((int)A.size() == N - 1) {
if (ps(A + s3 + A + s4) == (int)A.size() + 1) {
if (ps(A + s3) == (int)A.size() + 1 )
A += s3;
else
A += s4;
}
else
A.push_back(s0[0]);
}
// cout << A << endl;
return A;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |