Submission #1302783

#TimeUsernameProblemLanguageResultExecution timeMemory
1302783kuratusCombo (IOI18_combo)C++20
30 / 100
13 ms456 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;



std::string guess_sequence(int N) {
  char fir;
  string ans;
  bool alsob=0;
  long long ab=press("AB");
  if(ab==0){
    if(press("X")==1)fir='X';
    else fir ='Y';
  }
  else if(ab==1){
    if(press("A")==1)fir = 'A';
    else fir = 'B';
  }
  else {
    fir = 'A';
    alsob=1;
  }
  ans.push_back(fir);
  vector<char> pos;
  if(fir!='A')pos.push_back('A');
  if(fir!='B')pos.push_back('B');
  if(fir!='X')pos.push_back('X');
  if(fir!='Y')pos.push_back('Y');
  if(alsob)ans.push_back('B');
  while(ans.size()!=N){
    string pre;
    pre+=ans;
    pre.push_back(pos[0]);
    pre+=ans;
    pre.push_back(pos[1]);
    long long cn = press(pre);
    if(cn==ans.size())ans.push_back(pos[2]);
    else {
      if(press(ans+pos[0])==ans.size()){
        ans.push_back(pos[1]);
      }
      else ans.push_back(pos[0]);
    } 
  }
  return ans;
  
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...