제출 #309722

#제출 시각아이디문제언어결과실행 시간메모리
309722lukameladzeCombo (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
# include <combo.h> # include <bits/stdc++.h> std::string guess_sequence(int N) { std::string pref; std::string p="AB"; int c=press(p); if (c) { p="A"; c=press(p); if (c) pref="A"; else pref="B"; } else { p="X"; c=press(p); if (c) pref="X"; else pref="Y"; } if (pref=="A") { while (pref.size()<N-1) { cout<<pref<<" 1"<<endl; p=pref+"B"+pref+"XY"+pref+"XB"+pref+"XX"; c=press(p); if(c==pref.size()+1) { pref+="B"; } else if (c==pref.size()+2) { pref+="X"; } else pref+="Y"; } c=press(pref+"X"); if (c==N) pref+="X"; else { c=press(pref+"Y"); if (c==N) pref+="Y"; if (pref.size()!=N) pref+="B"; } } if (pref=="X") { while (pref.size()<N-1) { // cout<<pref<<" 1"<<endl; p=pref+"B"+pref+"AY"+pref+"AB"+pref+"AA"; c=press(p); if(c==pref.size()+1) { pref+="B"; } else if (c==pref.size()+2) { pref+="A"; } else pref+="Y"; } c=press(pref+"A"); if (c==N) pref+="A"; else { c=press(pref+"Y"); if (c==N) pref+="Y"; if (pref.size()!=N) pref+="B"; } } if (pref=="B") { while (pref.size()<N-1) { p=pref+"A"+pref+"XY"+pref+"XA"+pref+"XX"; c=press(p); if(c==pref.size()+1) { pref+="A"; } else if (c==pref.size()+2) { pref+="X"; } else pref+="Y"; } c=press(pref+"X"); if (c==N) pref+="X"; else { c=press(pref+"Y"); if (c==N) pref+="Y"; if (pref.size()!=N) pref+="A"; } } if (pref=="Y") { while (pref.size()<N-1) { p=pref+"B"+pref+"XA"+pref+"XB"+pref+"XX"; c=press(p); if(c==pref.size()+1) { pref+="B"; } else if (c==pref.size()+2) { pref+="X"; } else pref+="A"; } // cout<<pref<<endl; c=press(pref+"X"); if (c==N) pref+="X"; else { c=press(pref+"A"); if (c==N) pref+="A"; if (pref.size()!=N) pref+="B"; } } return pref; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:29: 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 (pref.size()<N-1)
      |                  ~~~~~~~~~~~^~~~
combo.cpp:29:12: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |            cout<<pref<<" 1"<<endl;
      |            ^~~~
      |            std::cout
In file included from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:75,
                 from combo.cpp:2:
/usr/include/c++/10/iostream:61:18: note: 'std::cout' declared here
   61 |   extern ostream cout;  /// Linked to standard output
      |                  ^~~~
combo.cpp:29:30: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   29 |            cout<<pref<<" 1"<<endl;
      |                              ^~~~
      |                              std::endl
In file included from /usr/include/c++/10/istream:39,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from combo.cpp:2:
/usr/include/c++/10/ostream:681:5: note: 'std::endl' declared here
  681 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
combo.cpp:32:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:51:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:57:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:62:15: 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(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:67:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:81:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   81 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:87:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   87 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:91:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:96:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:111:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  111 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~
combo.cpp:117:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  117 |        while (pref.size()<N-1)
      |               ~~~~~~~~~~~^~~~
combo.cpp:121:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  121 |           if(c==pref.size()+1)
      |              ~^~~~~~~~~~~~~~~
combo.cpp:126:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  126 |           if (c==pref.size()+2)
      |               ~^~~~~~~~~~~~~~~
combo.cpp:141:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  141 |         if (pref.size()!=N)
      |             ~~~~~~~~~~~^~~