Submission #763883

#TimeUsernameProblemLanguageResultExecution timeMemory
763883ind1vCombo (IOI18_combo)C++11
100 / 100
26 ms552 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string guess_sequence(int n) {
  string ans;
  set<string> s = {"A", "B", "X", "Y"};
  string cope = ans + 'A' + ans + 'B';
  int d = press(cope);
  if (d >= 1) {
    cope = ans + 'A';
    d = press(cope);
    if (d >= 1) {
      ans += 'A';
      s.erase("A");
    } else {
      ans += 'B';
      s.erase("B");
    }
  } else {
    cope = ans + 'X';
    d = press(cope);
    if (d >= 1) {
      ans += 'X';
      s.erase("X");
    } else {
      ans += 'Y';
      s.erase("Y");
    }
  }
  vector<string> cand;
  for (auto &x : s) {
    cand.emplace_back(x);
  }
  for (int i = 2; i <= n; i++) {
    if (i == n) {
      string cope = ans + cand[0] + ans + cand[1];
      int d = press(cope);
      if (d >= i) {
        cope = ans + cand[0];
        d = press(cope);
        if (d >= i) {
          ans += cand[0];
        } else {
          ans += cand[1];
        }
      } else {
        ans += cand[2];
      }
    } else {
      string cope = ans + cand[0] + cand[0] + ans + cand[0] + cand[1] + ans + cand[0] + cand[2] + ans + cand[1];
      int d = press(cope);
      if (d >= i + 1) {
        ans += cand[0];
      } else if (d >= i) {
        ans += cand[1];
      } else {
        ans += cand[2];
      }
    }
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...