Submission #1237537

#TimeUsernameProblemLanguageResultExecution timeMemory
1237537dssfsuper2Combo (IOI18_combo)C++20
100 / 100
7 ms484 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string guess_sequence(int N) {
  string known = "";
  int gl = press("AB");
  string pref;
  if (gl>0){
    if(press("A"))pref="A";
    else pref = "B";
  }
  else{
    if(press("X"))pref="X";
    else pref="Y";
  }
  char first = pref[0];
  vector<char> av;
  for(auto thing:{'A', 'B', 'X', 'Y'})if(thing!=first)av.push_back(thing);

  while(pref.size()<N-1){
    int x = press(pref+av[0]+av[0]+pref+av[0]+av[1]+pref+av[0]+av[2]+pref+av[1]);
    char c;
    if(x>=pref.size()+2)c=av[0];
    else if(x>=pref.size()+1)c=av[1];
    else c=av[2];
    pref.push_back(c);
  }
  if(pref.size()==N)return pref;
  int x = press(pref+av[0]);
  if(x==N)return pref+av[0];
  x= press(pref+av[1]);
  if(x==N)return pref+av[1];
  return pref+av[2];
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...