Submission #1256711

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

std::string guess_sequence(int N) {
  vector<char> op = {'A', 'B', 'X', 'Y'};

  // FIND first char  with BS
  string s = "";

  if(press("AB")) {
    if (press("A")) s+="A", op.erase(op.begin());
    else s += "B", op.erase(op.begin()+1);
  } else {
    if (press("X")) s+="X", op.erase(op.begin()+2);
    else s+="Y", op.erase(op.begin()+3);
  }

  for (int i = 1; i < N-1; i++) {
    int k = press(s+op[0]+s+op[1]+op[0]+s+op[1]+op[1]+s+op[1]+op[2]);
    if(k==i) s+= op[2];
    else if (k==i+1) s+=op[0];
    else s+=op[1];
  }
  if (N==1) return s;

  if(press(s+op[0])==N) s+=op[0];
  else if (press(s+op[1])==N) s+= op[1];
  else s+=op[2];
  return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...