제출 #989773

#제출 시각아이디문제언어결과실행 시간메모리
989773mannshah1211콤보 (IOI18_combo)C++17
30 / 100
29 ms956 KiB
/**
 *    author: tourist
 *    created:
**/
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif

vector<string> alphabet = {"A", "B", "X", "Y"};

string guess_sequence(int n) {
  string firs = "?", ans;
  for (int i = 0; i < 3; i++) {
    if (press(alphabet[i]) == 1) {
      firs = alphabet[i];
      break;
    }
  }
  if (firs == "?") {
    firs = alphabet[3];
  }
  ans += firs;
  vector<int> possible;
  int cnt = 0;
  for (int i = 0; i < 4; i++) {
    if (alphabet[i] != firs && cnt < 2) {
      possible.push_back(i);
      cnt++;
    }
  }
  for (int i = 1; i < n; i++) {
    bool found = false;
    for (int x : possible) {
      if (press(ans + alphabet[x]) == i + 1) {
        ans += alphabet[x];
        found = true;
        break;
      }
    }
    if (!found) {
      for (int i = 3; i >= 0; i--) {
        if (alphabet[i] != firs) {
          ans += alphabet[i];
          break;
        }
      }
    }
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...