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>
#include <combo.h>
using namespace std;
#define nl endl
string global = "";
// int press(string x){
// int a = 0;
// int ans = 0;
// for(char c : x){
// if(global[a] == c){
// a++;
// ans = max(a, ans);
// }
// else{
// a = 0;
// }
// }
// cerr << x << " " << ans << endl;
// return ans;
// }
string t[] = {"A", "B", "X", "Y"};
string guess_sequence(int n){
string ret;
string f="";
if(press("AB")){
if(press("A")) f += "A";
else f+= "B";
}
else{
if(press("X")) f += "X";
else f+="Y";
}
vector<string> want;
for(int i = 0; i < 4; i++){
if(t[i] != f){
want.push_back(t[i]);
}
}
ret = f;
if(n == 1){
return ret;
}
for(string x : want){
cerr << x<< " ";
}
cerr << nl;
for(int i = 0; i < n-2; i++){
string query = "";
query += ret + want[0] + ret + want[1] + want[0] + ret + want[1] + want[2] + ret + want[1] + want[1];
int res = press(query);
if(res == (int)ret.size()) ret += want[2];
else if(res == (int)ret.size() + 1) ret += want[0];
else ret += want[1];
}
if(press(ret + want[0])==n) ret += want[0];
else if(press(ret + want[1]) == n) ret += want[1];
else ret += want[2];
return ret;
}
// void run(int n, string c){
// global = c;
// cout << guess_sequence(n);
// }
// int main(){
// run(5, "XYYYY");
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |