제출 #884423

#제출 시각아이디문제언어결과실행 시간메모리
884423AkibAzmain콤보 (IOI18_combo)C++17
100 / 100
12 ms1844 KiB
#include <bits/stdc++.h>
using namespace std;
#include "combo.h"

std::string guess_sequence(int n) {
  std::string p = "";
  string s;
  if (press ("AB"))
    {
      if (press ("A")) s = "A";
      else s = "B";
    }
  else
    {
      if (press ("X")) s = "X";
      else s = "Y";
    }
  if (n == 1) return s;
  char c1 = 'A', c2 = 'B', c3 = 'X';
  if (s[0] == c1) c1 = 'Y';
  if (s[0] == c2) c2 = 'Y';
  if (s[0] == c3) c3 = 'Y';
  for (int i = 1; i < n - 1; ++i)
    switch (press (s + c1
                   + s + c2 + c1
                   + s + c2 + c2
                   + s + c2 + c3)
            - s.size ())
      {
      case 0:
        s += c3;
        break;
      case 1:
        s += c1;
        break;
      case 2:
        s += c2;
        break;
      }
  if (press (s + c1) == n) s += c1;
  else if (press (s + c2) == n) s += c2;
  else s += c3;
  return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...