제출 #756164

#제출 시각아이디문제언어결과실행 시간메모리
756164thinknoexit콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h"
#include <iostream>
using namespace std;
string guess_sequence(int N) {
  string ans = "";
  string p = "";
  if (press("AB")) {
    if (press("A")) ans = "A", p = "BXY";
    else ans = "B", p = "AXY";
  }
  else {
    if (press("X")) ans = "X", p = "ABY";
    else ans = "Y", p = "ABX";
  }
  while (p.size() != N - 1) {
    int t = press(p + c[0] + p + c[1] + c[0] + p + c[1] + c[1] + p + c[1] + c[2]);
    if (p.size() == t - 1) p += c[0];
    else if (p.size() == t - 2) p += c[1];
    else p += c[2];
  }
  if (p.size() != press(p + c[0])) p += c[0];
  else if (p.size() != press(p + c[1])) p += c[1];
  else p += c[2];
  return p;
}

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |   while (p.size() != N - 1) {
      |          ~~~~~~~~~^~~~~~~~
combo.cpp:16:23: error: 'c' was not declared in this scope
   16 |     int t = press(p + c[0] + p + c[1] + c[0] + p + c[1] + c[1] + p + c[1] + c[2]);
      |                       ^
combo.cpp:17:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |     if (p.size() == t - 1) p += c[0];
      |         ~~~~~~~~~^~~~~~~~
combo.cpp:18:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     else if (p.size() == t - 2) p += c[1];
      |              ~~~~~~~~~^~~~~~~~
combo.cpp:21:29: error: 'c' was not declared in this scope
   21 |   if (p.size() != press(p + c[0])) p += c[0];
      |                             ^