제출 #742254

#제출 시각아이디문제언어결과실행 시간메모리
742254Osplei콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string p = ""; p="AB"; int coins = press(p); if (coins!=0) { p="A"; coins = press(p); if (coins==0) p="B"; } else { p="X"; coins = press(p); if (coins==0) p="Y"; } string S = p; if (p=="A"){ while (S.size()!=N-1){ p=S; p+='B'; p+=S; p+="XX"; p+=S; p+="XB"; p+=S; p+="XY"; coins = press(p); if (coins == S.size()) S+='Y'; else if (coins == S.size()+1) S+='B'; else S+='X'; } p=S; p+='B'; coins = press(p); if (coins == N) S+='B'; else { p=S; p+='X'; coins = press(p); if (coins == N) S+='X'; else S+='Y'; } } else if (p=="B"){ while (S.size()!=N-1){ p=S; p+='A'; p+=S; p+="XX"; p+=S; p+="XA"; p+=S; p+="XY"; coins = press(p); if (coins == S.size()) S+='Y'; else if (coins == S.size()+1) S+='A'; else S+='X'; } p=S; p+='A'; coins = press(p); if (coins == N) S+='A'; else { p=S; p+='X'; coins = press(p); if (coins == N) S+='X'; else S+='Y'; } } else if (p=="X"){ while (S.size()!=n-1){ p=S; p+='B'; p+=S; p+="AA"; p+=S; p+="AB"; p+=S; p+="AY"; coins = press(p); if (coins == S.size()) S+='Y'; else if (coins == S.size()+1) S+='B'; else S+='A'; } p=S; p+='B'; coins = press(p); if (coins == N) S+='B'; else { p=S; p+='A'; coins = press(p); if (coins == N) S+='A'; else S+='Y'; } } else { while (S.size()!=n-1){ p=S; p+='B'; p+=S; p+="XX"; p+=S; p+="XB"; p+=S; p+="XA"; coins = press(p); if (coins == S.size()) S+='A'; else if (coins == S.size()+1) S+='B'; else S+='X'; } p=S; p+='B'; coins = press(p); if (coins == N) S+='B'; else { p=S; p+='X'; coins = press(p); if (coins == N) S+='X'; else S+='A'; } } return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     while (S.size()!=N-1){
      |            ~~~~~~~~^~~~~
combo.cpp:39:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |       if (coins == S.size()) S+='Y';
      |           ~~~~~~^~~~~~~~~~~
combo.cpp:40:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |       else if (coins == S.size()+1) S+='B';
      |                ~~~~~~^~~~~~~~~~~~~
combo.cpp:60:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     while (S.size()!=N-1){
      |            ~~~~~~~~^~~~~
combo.cpp:72:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |       if (coins == S.size()) S+='Y';
      |           ~~~~~~^~~~~~~~~~~
combo.cpp:73:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |       else if (coins == S.size()+1) S+='A';
      |                ~~~~~~^~~~~~~~~~~~~
combo.cpp:93:22: error: 'n' was not declared in this scope
   93 |     while (S.size()!=n-1){
      |                      ^
combo.cpp:105:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  105 |       if (coins == S.size()) S+='Y';
      |           ~~~~~~^~~~~~~~~~~
combo.cpp:106:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |       else if (coins == S.size()+1) S+='B';
      |                ~~~~~~^~~~~~~~~~~~~
combo.cpp:126:22: error: 'n' was not declared in this scope
  126 |     while (S.size()!=n-1){
      |                      ^
combo.cpp:138:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  138 |       if (coins == S.size()) S+='A';
      |           ~~~~~~^~~~~~~~~~~
combo.cpp:139:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |       else if (coins == S.size()+1) S+='B';
      |                ~~~~~~^~~~~~~~~~~~~