Submission #348555

#TimeUsernameProblemLanguageResultExecution timeMemory
348555HalogenCombo (IOI18_combo)C++14
5 / 100
2 ms200 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
std::string guess_sequence(int N) {
  vector<char> lst{'A', 'B', 'X', 'Y'};
  std::string p = "";

  if (press(p + lst[0] + p + lst[1]) >= p.size() + 1)
  {
    if (press(p + lst[0]) == p.size() + 1){
      p += lst[0];
      lst.erase(lst.begin() + 0);
    }
    else {
      p += lst[1];
      lst.erase(lst.begin() + 1);
    }
  }
  else if (press(p + lst[2]) == p.size() + 1) {
    p += lst[2];
    lst.erase(lst.begin() + 2);
  }
  else {
    p += lst[3];
    lst.erase(lst.begin() + 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 (press(p + lst[0] + p + lst[1]) != 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:8:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |   if (press(p + lst[0] + p + lst[1]) >= p.size() + 1)
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:10:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     if (press(p + lst[0]) == p.size() + 1){
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:19:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   else if (press(p + lst[2]) == p.size() + 1) {
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...