Submission #136508

#TimeUsernameProblemLanguageResultExecution timeMemory
136508shenxyCombo (IOI18_combo)C++11
Compilation error
0 ms0 KiB
#include "combo.h"
#include <string>
#include <algorithm>
using namespace std;
string guess_sequence(int N) {
  string p = "", k = "";
  if (press("AB") != 0) {
    if (press("A") != 0) {
      p = "A";
      k = "BXY";
    } else {
      p = "B";
      k = "AXY";
    }
  else {
    if (press("X") != 0) {
      p = "X";
      k = "ABY";
    } else {
      p = "Y";
      k = "ABX";
    }
  }
  while (p.length() < N - 1) {
    int x = press(p + k[0] + k[1] + p + k[0] + k[2] + p + k[0] + k[0] + p + k[1]);
    if (x == p.length() + 2) p += k[0];
    else if (x == p.length() + 1) p += k[1];
    else p += k[2];
  }
  if (press(p + k[0]) == N) return p + k[0];
  else if (press(p + k[1]) == N) return p + k[1];
  else return p + k[2];
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:3: error: expected '}' before 'else'
   15 |   else {
      |   ^~~~
combo.cpp:7:25: note: to match this '{'
    7 |   if (press("AB") != 0) {
      |                         ^
combo.cpp:24:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   while (p.length() < N - 1) {
      |          ~~~~~~~~~~~^~~~~~~
combo.cpp:26:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     if (x == p.length() + 2) p += k[0];
      |         ~~^~~~~~~~~~~~~~~~~
combo.cpp:27:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     else if (x == p.length() + 1) p += k[1];
      |              ~~^~~~~~~~~~~~~~~~~