제출 #1320229

#제출 시각아이디문제언어결과실행 시간메모리
1320229AMel0n콤보 (IOI18_combo)C++20
100 / 100
8 ms472 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;

string guess_sequence(int N) {
  string S = "";
  string G;
  G = "AB";
  vector<string> victor;
  if (press(G)) {
    G = "A";
    if (press(G)) {
      S += "A";
      victor = {"B", "XB", "XX", "XY"};
    } else {
      S += "B";
      victor = {"A", "XA", "XX", "XY"};
    }
  } else {
    G = "X";
    if (press(G)) {
      S += "X";
      victor = {"A", "BA", "BB", "BY"};
    } else {
      S += "Y";
      victor = {"A", "BA", "BB", "BX"};
    }
  }
  for(int i = 1; i < N-1; i++) {
    G = "";
    for(string x: victor) {
      G += S + x;
    }
    int coin = press(G);
    if (coin == S.size() + 1) {
      if (S[0] == 'A') S += "B";
      else S += "A";
    } else if (coin == S.size() + 2) {
      if (S[0] == 'A' || S[0] == 'B') S += "X";
      else S += "B";
    } else {
      if (S[0] == 'Y') S += "X";
      else S += "Y";
    }
  }
  if (N == 1) return S;
  if (S[0] == 'A') {
    G = S + "X" + S + "Y";
    if (press(G) == N) {
      G = S + "X";
      if (press(G) == N) S += "X";
      else S += "Y";
    } else S += "B";
  } else if (S[0] == 'B') {
    G = S + "X" + S + "Y";
    if (press(G) == N) {
      G = S + "X";
      if (press(G) == N) S += "X";
      else S += "Y";
    } else S += "A";
  } else if (S[0] == 'X') {
    G = S + "A" + S + "Y";
    if (press(G) == N) {
      G = S + "A";
      if (press(G) == N) S += "A";
      else S += "Y";
    } else S += "B";
  } else {
    G = S + "X" + S + "A";
    if (press(G) == N) {
      G = S + "X";
      if (press(G) == N) S += "X";
      else S += "A";
    } else S += "B";
  }
  return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...