Submission #76736

#TimeUsernameProblemLanguageResultExecution timeMemory
76736shoemakerjoCombo (IOI18_combo)C++14
100 / 100
56 ms564 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

string guess_sequence(int N) {
  string p = "";
  if (press("AB") > 0) {
    if (press("A") > 0) p += 'A';
    else p += 'B';
  }
  else {
    if (press("X") > 0) p += 'X';
    else p += 'Y';
  }
  if (N == 1) return p;
  vector<string> stuff;
  if (p != "A") stuff.push_back("A");
  if (p != "B") stuff.push_back("B");
  if (p != "X") stuff.push_back("X");
  if (p != "Y") stuff.push_back("Y");

  for (int i = 2; i < N; i++) {

    string guess = p + stuff[0] + p + stuff[1] + stuff[0] + 
      p + stuff[1] + stuff[1] + p + stuff[1] + stuff[2];

    int val = press(guess);
    if (val == i) p += stuff[0];
    else if (val == i+1) p += stuff[1];
    else p += stuff[2];

    // cout << "I think the prefix is: " << p << endl;
  }
  if (press(p + "A" + p + "B") == N) {
    if (press(p+"A") == N) p += 'A';
    else p += 'B';
  }
  else {
    if (press(p + "X") == N) p += 'X';
    else p += 'Y';
  }
  return p;

}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...