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 V vector
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define sz (int)s.size()
string guess_sequence(int n){
V<string> arr = {"A","B","X","Y"};
string s;
// find first char
{
int ax = press("AX"), bx = press("BX");
if(ax && bx) s = "X";
else if(ax) s = "A";
else if(bx) s = "B";
else s = "Y";
}
if(sz==n) return s;
// put s[0] as last char
{
int i = 0;
while(arr[i] != s) i++;
swap(arr[i], arr[3]);
}
//cout << s << endl;
rep(i,1,n-1){
string t = s + arr[0] + arr[0]
+ s + arr[0] + arr[1]
+ s + arr[0] + arr[2]
+ s + arr[1]
;
//cout << t << endl;
int len = press(t);
if(len==sz) s += arr[2];
else if(len==sz+1) s += arr[1];
else s += arr[0];
}
// last char
string t = s + arr[0] + s + arr[1];
if(press(t) > sz){
t = s + arr[0];
if(press(t) > sz) s += arr[0];
else s += arr[1];
}
else s += arr[2];
//assert(sz == n);
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |