Submission #534571

#TimeUsernameProblemLanguageResultExecution timeMemory
534571almothana05Combo (IOI18_combo)C++14
97 / 100
31 ms668 KiB
#include "combo.h" #include <cassert> using namespace std; string cmp , erg = "" ; int numm = 0 , nummer = 0; char buch; string guess_sequence(int menge) { string p = ""; p = "AB"; numm = press(p); if(numm > 0){ p = 'A'; numm = press(p); if(numm == 1){ erg += 'A'; buch = 'A'; } else{ erg += 'B'; buch = 'B'; } } else{ p = 'X'; numm = press(p); if(numm == 1){ erg += 'X'; buch = 'X'; } else{ erg += 'Y'; buch = 'Y'; } } if(buch == 'A'){ cmp = "BXY"; } else if(buch == 'B'){ cmp = "AXY"; } else if(buch == 'X'){ cmp = "ABY"; } else{ cmp = "ABX"; } int rechner = 0; while(erg.size() < menge - 1 ){ numm = press(erg + cmp[0] + erg + cmp[1] + cmp[0] + erg + cmp[1] + cmp[1] + erg + cmp[1] + cmp[2]); if(numm == erg.size()){ erg += cmp[2]; } else if(numm - 1 == erg.size()){ erg += cmp[0]; } else if(numm - 2 == erg.size()){ erg += cmp[1]; } } p = ""; if(erg.size() < menge){ erg += cmp[0]; numm = press(erg); if(numm == erg.size()){ return erg; } erg.pop_back(); erg += cmp[1]; numm = press(erg); if(numm == erg.size()){ return erg; } erg.pop_back(); erg += cmp[2]; numm = press(erg); if(numm == erg.size()){ return erg; } erg.pop_back(); } assert(erg.size() == menge); return erg; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |   while(erg.size() < menge - 1 ){
      |         ~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:50:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     if(numm == erg.size()){
      |        ~~~~~^~~~~~~~~~~~~
combo.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     else if(numm - 1 == erg.size()){
      |             ~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:56:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |     else if(numm - 2 == erg.size()){
      |             ~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:61:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   61 |   if(erg.size() < menge){
      |      ~~~~~~~~~~~^~~~~~~
combo.cpp:64:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     if(numm == erg.size()){
      |        ~~~~~^~~~~~~~~~~~~
combo.cpp:71:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |     if(numm == erg.size()){
      |        ~~~~~^~~~~~~~~~~~~
combo.cpp:78:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     if(numm == erg.size()){
      |        ~~~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from combo.cpp:2:
combo.cpp:83:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   83 |   assert(erg.size() == menge);
      |          ~~~~~~~~~~~^~~~~~~~
combo.cpp:47:7: warning: unused variable 'rechner' [-Wunused-variable]
   47 |   int rechner = 0;
      |       ^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...