제출 #526038

#제출 시각아이디문제언어결과실행 시간메모리
526038benjaminkleyn콤보 (IOI18_combo)C++17
0 / 100
1 ms200 KiB
#include "combo.h"

std::string guess_sequence(int N) {
  std::string S;
  std::string pos;
  // find first letter (3 presses)
  if (press("A")) pos = "BXY", S = "A";
  else if (press("B")) pos = "AXY", S = "B";
  else if (press("X")) pos = "ABY", S = "X";
  else pos = "ABX", S = "Y";
  // find next N-1 letters (N-1 presses)
  for (int i = 0; i < N - 1; i++)
  {
      // the length of this string will always be < 4N.
      int coins = press(S + pos[0] + pos[0] + S + pos[0] + pos[1] + S + pos[0] + pos[2] + S + pos[1]);
      if (coins == i + 3)
        S += pos[0];
      else if (coins == i + 2)
        S += pos[1];
      else
        S += pos[2];
  }
  return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...