제출 #427654

#제출 시각아이디문제언어결과실행 시간메모리
427654daanolav콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <string> using namespace std; string characters[4]; std::string guess_sequence(int N) { characters[0] = "A"; characters[1] = "B"; characters[2] = "X"; characters[3] = "Y"; string start = ""; int res = press("AB"); if(res >= 1) { if(res == 2) { start = "AB"; } else { res = press("AX"); if(res == 0) { start = "B"; } else if(res == 1) { start = "A"; } else { start = "AX"; } } } else { res = press("XA"); if(res == 0) { start = "Y"; } else if(res == 1) { start = "X"; } else { start = "XA"; } } cerr << start << endl; string first = "" + start.at(0); string notFirst[3]; int i = 0; for(string c : characters) { if(first == c) { continue; } notFirst[i] = c; ++i; } while(start.size() != N) { res = press(start + notFirst[0] + start + notFirst[1] + notFirst[0]); if(res == start.size()) { start = start + notFirst[2]; } else if(res == start.size() + 2) { start = start + notFirst[1] + notFirst[0]; } else { res = press(start + notFirst[0] + notFirst[0]); if(res == start.size()) { start = start + notFirst[1]; } else if(res == start.size() + 2) { start = start + notFirst[0] + notFirst[0]; } else { start = start + notFirst[0]; } } } return ""; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:5: error: 'cerr' was not declared in this scope
   42 |     cerr << start << endl;
      |     ^~~~
combo.cpp:2:1: note: 'std::cerr' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
    1 | #include "combo.h"
  +++ |+#include <iostream>
    2 | #include <string>
combo.cpp:42:22: error: 'endl' was not declared in this scope
   42 |     cerr << start << endl;
      |                      ^~~~
combo.cpp:2:1: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
    1 | #include "combo.h"
  +++ |+#include <ostream>
    2 | #include <string>
combo.cpp:54:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   54 |     while(start.size() != N) {
      |           ~~~~~~~~~~~~~^~~~
combo.cpp:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |         if(res == start.size()) {
      |            ~~~~^~~~~~~~~~~~~~~
combo.cpp:58:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |         } else if(res == start.size() + 2) {
      |                   ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:62:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |             if(res == start.size()) {
      |                ~~~~^~~~~~~~~~~~~~~
combo.cpp:64:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |             } else if(res == start.size() + 2) {
      |                       ~~~~^~~~~~~~~~~~~~~~~~~