제출 #1208946

#제출 시각아이디문제언어결과실행 시간메모리
1208946thewizardman콤보 (IOI18_combo)C++20
5 / 100
0 ms408 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;

string str[3] = {"BB", "XB", "XX"};
string mt[3][3] = {
  {"Y", "Y", "Y"},
  {"XY", "BX", "BY"},
  {"BB", "XB", "XX"}
};

string guess_sequence(int n) {
  string s;
  if (press("AB")) {
    if (press("A")) s += "A";
    else s += "B";
  } else {
    if (press("X")) s += "X";
    else s += "Y";
  }
  for (auto& st: str) for (auto& c: st) if (c == s[0]) c = 'A';
  for (auto& a: mt) for (auto& st: a) for (auto& c: st) if (c == s[0]) c = 'A';

  int c = 0;
  while (s.length() < n) {
    string p;
    for (auto st: str) p += s + st;
    int i = press(p) - s.length();
    c++;
    if (i == 0) {
      s += mt[0][0];
    } else {
      s += mt[i][press(s + mt[i][2]) - s.length()];
    }
  }
  if (s.length() == n+1) s.pop_back();
  return s;
}

/*
  wlog a is first
    bb xb xx
    0 -> yb yx yy
    1 -> bx by xy
    2 -> bb xb xx
*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...