제출 #161090

#제출 시각아이디문제언어결과실행 시간메모리
161090giorgikob콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <string> std::string guess_sequence(int N) { std::string S = ""; int x = press("AB"); if(x == 1){ x = press("A"); if(x==1){ S += 'A'; } else { S += 'B'; } } else { x = press("X"); if(x==1){ S += "X"; } else { S += "Y"; } } string c1,c2,c3; if(S=="X") c1 = "A", c2 = "B", c3 = "Y"; if(S=="Y") c1 = "A", c2 = "B", c3 = "X"; if(S=="A") c1 = "B", c2 = "X", c3 = "Y"; if(S=="B") c1 = "A", c2 = "X", c3 = "Y"; for(int i=1;i<N;i++){ int x = (S+c1+S+c2+c1+S+c2+c2+S+c2+c3); if(x==S.size()); S += c3; if(x==S.size()+1) S += c1; if(x==S.size()+2) S += c2; } return S; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:23:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
   23 |     string c1,c2,c3;
      |     ^~~~~~
      |     std::string
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
combo.cpp:24:16: error: 'c1' was not declared in this scope
   24 |     if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
      |                ^~
combo.cpp:24:26: error: 'c2' was not declared in this scope
   24 |     if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
      |                          ^~
combo.cpp:24:36: error: 'c3' was not declared in this scope
   24 |     if(S=="X") c1 = "A", c2 = "B", c3 = "Y";
      |                                    ^~
combo.cpp:25:16: error: 'c1' was not declared in this scope
   25 |     if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
      |                ^~
combo.cpp:25:26: error: 'c2' was not declared in this scope
   25 |     if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
      |                          ^~
combo.cpp:25:36: error: 'c3' was not declared in this scope
   25 |     if(S=="Y") c1 = "A", c2 = "B", c3 = "X";
      |                                    ^~
combo.cpp:26:16: error: 'c1' was not declared in this scope
   26 |     if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
      |                ^~
combo.cpp:26:26: error: 'c2' was not declared in this scope
   26 |     if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
      |                          ^~
combo.cpp:26:36: error: 'c3' was not declared in this scope
   26 |     if(S=="A") c1 = "B", c2 = "X", c3 = "Y";
      |                                    ^~
combo.cpp:27:16: error: 'c1' was not declared in this scope
   27 |     if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
      |                ^~
combo.cpp:27:26: error: 'c2' was not declared in this scope
   27 |     if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
      |                          ^~
combo.cpp:27:36: error: 'c3' was not declared in this scope
   27 |     if(S=="B") c1 = "A", c2 = "X", c3 = "Y";
      |                                    ^~
combo.cpp:30:20: error: 'c1' was not declared in this scope
   30 |         int x = (S+c1+S+c2+c1+S+c2+c2+S+c2+c3);
      |                    ^~
combo.cpp:30:25: error: 'c2' was not declared in this scope
   30 |         int x = (S+c1+S+c2+c1+S+c2+c2+S+c2+c3);
      |                         ^~
combo.cpp:30:44: error: 'c3' was not declared in this scope
   30 |         int x = (S+c1+S+c2+c1+S+c2+c2+S+c2+c3);
      |                                            ^~
combo.cpp:31:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if(x==S.size());
      |            ~^~~~~~~~~~
combo.cpp:33:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if(x==S.size()+1)
      |            ~^~~~~~~~~~~~
combo.cpp:35:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         if(x==S.size()+2)
      |            ~^~~~~~~~~~~~