Submission #349026

#TimeUsernameProblemLanguageResultExecution timeMemory
349026Maqsut_03Combo (IOI18_combo)C++14
100 / 100
39 ms512 KiB
#include <combo.h>
std::string guess_sequence(int N) {
  char lst[4] = {'A', 'B', 'X', 'Y'};
  std::string p = "";
 
  if (press(lst[0] + p + lst[1]) >= 1) {
    if (press(p + lst[0]) == 1){
      p += lst[0];
      lst[0] = lst[3];
    }
    else {
      p += lst[1];
      lst[1] = lst[3];
    }
  }
  else if (press(p + lst[2]) == 1) {
    p += lst[2];
    lst[2] = lst[3];
  }
  else {
    p += lst[3];
  }
 
  for (int j = 2; j < N; j++) {
    int result = press(p + lst[0] + p + lst[1] + lst[0] + p + lst[1] + lst[1] + p + lst[1] + lst[2]);
 
    if (result == j) p += lst[0];
    else if (result == j + 1) p += lst[1];
    else p += lst[2];
  }
 
  if (p.size() == N) return p;
  else if (press(p + lst[2]) == N) p += lst[2];
  else if (press(p + lst[0]) == N) p += lst[0];
  else p += lst[1];
 
  return p;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |   if (p.size() == N) return p;
      |       ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...