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"
#define ll long long
#define ff first
#define ss second
#define ln endl
using namespace std;
std::string guess_sequence(int N) {
  string ans="";
  ll tmp = press("AABB");
  if (tmp!=0){
    tmp = press("AA");
    if (tmp){
      ans+="A";
    }else ans+="B";
  }else{
    tmp = press("XX");
    if (tmp){
      ans+="X";
    }else{
      ans+="Y";
    }
  }
  char start = ans[0];
  vector<char> pos = {'A', 'B', 'X', 'Y'};
  vector<char> chos;
  for (auto ch:pos) if (ch!=start) chos.emplace_back(ch);
  for (ll i=1;i<N-1; i++){
    string ask = ans; ask+=chos[0];
    for (auto ch:chos){
      ask+=ans; ask+=chos[1]; ask+=ch;
    }
    ll ret = press(ask);
    if (ret==i+1){
      ans+=chos[0];
    }else if (ret==i+2){
      ans+=chos[1];
    }else ans+=chos[2];
  }
  string ask = ans+chos[0]; ask+=ans; ask+=chos[1];
  ll ret = press(ask);
  if (ret==N){
    ret = press(ans+chos[0]);
    if (ret==N) ans+=chos[0];
    else ans+=chos[1];
  }else{
    ans+=chos[2];
  }
  return ans;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |