Submission #995539

#TimeUsernameProblemLanguageResultExecution timeMemory
995539MarszpaceCombo (IOI18_combo)C++17
100 / 100
22 ms2068 KiB
/*
 * With a little appreciation, in a mostly hollow tone, she says, "Delightful." As if the world has any meaning.
 * TASK : IOI18_combo
 * AUTHOR : Marszpace
*/

#include<bits/stdc++.h>
using namespace std;

int press(string p);

string guess_sequence(int N) {
  // First
  string pref="";
  {
  int c1 = press("AX"),c2;
  
  if(c1>=1){
    c2=press("A");
    if(c2>=1){pref.push_back('A');}
    else{pref.push_back('X');}
  }
  else{
    c2=press("B");
    if(c2>=1){pref.push_back('B');}
    else{pref.push_back('Y');}
  }

  }

  // 2 - N-1
  string button="ABXY";
  button.erase(find(button.begin(),button.end(),pref[0]));

  for(int i=2;i<=N-1;i++){
    int ans=press(
        pref+button[2]+button[0]+
        pref+button[2]+button[1]+
        pref+button[2]+button[2]+
        pref+button[1]);
    pref.push_back(button[ans-pref.size()]);
  }

  // Edge Case
  if(N==1){
    return pref;
  }

  // Last
  {
  int c1=press(pref+button[0]);
  if(c1-1==(int)pref.size()){
    pref.push_back(button[0]);
  }
  else{
    int c2=press(pref+button[1]);
    if(c2-1==(int)pref.size()){
      pref.push_back(button[1]);
    }
    else{
      pref.push_back(button[2]);
    }
  }
  }
  return pref;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...