제출 #1356293

#제출 시각아이디문제언어결과실행 시간메모리
1356293hewkawarCombo (IOI18_combo)C++17
100 / 100
5 ms516 KiB
#include "combo.h"
#include <bits/stdc++.h>

std::string guess_sequence(int N) {
  std::string S = "";

  std::set<char> combo = {'A', 'B', 'X', 'Y'};

  for (int i = 0; i < N; i++) {
    if (i == 0) {
      int ab = press("AB");
      if (ab == 2) {
        S += "AB";
        combo.erase('A');
        i++;
        continue;
      } else if (ab == 1) {
        int a = press("A");

        if (a == 1) {
          S += "A";
          combo.erase('A');
        } else {
          S += "B";
          combo.erase('B');
        }
        continue;
      } else {
        int x = press("X");

        if (x == 1) {
          S += "X";
          combo.erase('X');
        } else {
          S += "Y";
          combo.erase('Y');
        }
        continue;
      }
    } else if (i == N - 1) {
      char d1 = *next(combo.begin(), 0);
      char d2 = *next(combo.begin(), 1);
      char d3 = *next(combo.begin(), 2);

      if (press(S + d1) - S.size() == 1) {
        S += d1;
      } else if (press(S + d2) - S.size() == 1) {
        S += d2;
      } else {
        S += d3;
      }
    } else {
      char d1 = *next(combo.begin(), 0);
      char d2 = *next(combo.begin(), 1);
      char d3 = *next(combo.begin(), 2);

      int ask = press(S + d1 + d1 + S + d1 + d2 + S + d1 + d3 + S + d2);

      if (ask - S.size() == 2) {
        S = S + d1;
      } else if (ask - S.size() == 1) {
        S = S + d2;
      } else {
        S = S + d3;
      }
    }
  }

  return S;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…