제출 #1175876

#제출 시각아이디문제언어결과실행 시간메모리
1175876rafsanamin2020콤보 (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include <string>
#include <iostream>
#include "combo.h"

using namespace std;

std::string guess_sequence(int N)
{
  int f = press("AB"), s = press("BX"), cnt = 1;
  string P = "", S = "", Ct = "ABXY", C = "";

  if (f > 0 && s > 0)
    S.push_back('B');
  else if (f > 0 && s <= 0)
    S.push_back('A');
  else if (f <= 0 && s > 0)
    S.push_back('X');
  else
    S.push_back('Y');

  for (char v : Ct)
  {
    if (v != S[0])
      C.push_back(v);
  }

  while (cnt < N - 1)
  {
    P = "";
    P += (S + C[0]);
    for (int i = 0; i < 3; i++)
    {
      P += (S + C[1] + C[i]);
    }

    int q = press(P);
    if (q == cnt)
    {
      S += C[2];
    }
    else if (q == cnt + 1)
    {
      S += C[0];
    }
    else
    {
      S += C[1];
    }

        cnt++;
  }

  S += press(S + "B") > cnt ? "B" : press(S + "X") > cnt ? "X"
                                                         : "Y";

  return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...