Submission #415547

#TimeUsernameProblemLanguageResultExecution timeMemory
415547Mohammed_AtalahCombo (IOI18_combo)C++17
0 / 100
1 ms200 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;




std::string guess_sequence(int N) {
  cout << "expected: <= " <<  N + 2 << endl;
  char cs[4] = {'A', 'B', 'X', 'Y'};

  string res = "";

  // char cant = '0';
  // bool skip = false;

  string t1 = "";
  t1 += cs[0];
  t1 += cs[1];
  if (press(t1) >= 1) {

    t1[1] = cs[0];
    if (press(t1) == 1) {
      res += cs[0];
      cs[0] = cs[3];
    } else {
      res += cs [1];
      cs[1] = cs[3];
    }
  } else {
    string t2 = "";
    t2 += cs[2];
    t2 += cs[2];
    if (press(t2) == 1) {
      res += cs[2];
      cs[2] = cs[3];
    } else {
      res += cs[3];
    }

  }


  if (N == 1) {
    return res;
  }


  for (int i = 1; i < N; i++) {
    if (i + 1 == N) {
      string check = res;
      check += cs[0];
      check += res;
      check += cs[1];
      if (press(check) == i + 1) {
        string check2 = res;
        check2 += cs[0];
        if (press(check2) == i + 1) {
          res += cs[0];
        } else {
          res += cs[1];
        }
      } else {
        res += cs[2];
      }

    } else {
      string check = res;
      check += cs[0];
      check += cs[0];
      check += res;
      check += cs[0];
      check += cs[1];
      check += res;
      check += cs[0];
      check += cs[2];
      check += res;
      check += cs[1];
      int y = press(check);
      if (y == i + 1) {
        res += cs[1];
      } else if (y == i + 2) {
        res += cs[0];
      } else {
        res += cs[2];
      }

    }






  }

  // cout << res << endl;
  return res;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...