Submission #906954

#TimeUsernameProblemLanguageResultExecution timeMemory
906954MarinkovicCombo (IOI18_combo)C++14
0 / 100
0 ms344 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

string guess_sequence(int N) {
  string S = "";
  for(char c : "ABX") {
    int p = press(string(1, c));

    if(p == 1) {
      S.push_back(c); 
      break;
    }
  }

  if(S == "") S = "Y";
  string B = "ABXY";
  B.erase(B.find(S), 1);

  for(int i = 1; i < N-1; ++i) {
    string guess = S + B[0] + 
                  (S + B[1] + B[0]) + 
                  (S + B[1] + B[1]) + 
                  (S + B[1] + B[2]);

    int p = press(guess);
    if(p == 0) S.push_back(B[2]);
    if(p == 1) S.push_back(B[0]);
    if(p == 2) S.push_back(B[1]);
  }

  for(char c : B) {
    int p = press(S + c);

    if(p == N) {
      S.push_back(c); 
      break;
    }
  }

  return S;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...