Submission #1349905

#TimeUsernameProblemLanguageResultExecution timeMemory
1349905bbbiros콤보 (IOI18_combo)C++20
100 / 100
5 ms588 KiB
#include "combo.h"
std::string guess_sequence(int N)
{
  std::string ans = "";

  if (press("AB") > 0)
    if (press("A") > 0)
      ans = "A";
    else
      ans = "B";
  else if (press("X") > 0)
    ans = "X";
  else
    ans = "Y";
  std::string all = "ABXY";
  std::string rem = "";
  for (char c : all)
    if (c != ans[0])
      rem += c;
  char b, x, y;
  b = rem[0];
  x = rem[1];
  y = rem[2];
  for (int i = 2; i < N; i++)
  {
    int res = press((ans + b) + (ans + x + b) + (ans + x + x) + (ans + x + y));
    if (res == ans.size())
      ans += y;
    else if (res == ans.size() + 1)
      ans += b;
    else
      ans += x;
  }
  if (N > 1)
  {
    if (press(ans + b) == N)
      ans += b;
    else if (press(ans + x) == N)
      ans += x;
    else
      ans += y;
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...