Submission #706046

#TimeUsernameProblemLanguageResultExecution timeMemory
706046mseebacherCombo (IOI18_combo)C++17
100 / 100
28 ms636 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string s = ""; vector<char> se = {'A','B','X','Y'}; if(press("AB")){ s = press("A") ? 'A' : 'B'; }else{ s = press("X") ? 'X' : 'Y'; } se.erase(find(se.begin(),se.end(),s[0])); while(s.length() < n-1){ string zwischen = s+se[0]+se[0]+s+se[0]+se[1]+s+se[0]+se[2]+s+se[1]; int erg = press(zwischen); if(erg == s.length()+2){ s+=se[0]; }else if(erg == s.length()+1){ s+=se[1]; }else{ s+=se[2]; } } if(s.length() == n) return s; if(press(s+se[0]) == n) return s+se[0]; if(press(s+se[1]) == n) return s+se[1]; return s+se[2]; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   15 |   while(s.length() < n-1){
      |         ~~~~~~~~~~~^~~~~
combo.cpp:18:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |   if(erg == s.length()+2){
      |      ~~~~^~~~~~~~~~~~~~~
combo.cpp:20:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   }else if(erg == s.length()+1){
      |            ~~~~^~~~~~~~~~~~~~~
combo.cpp:26:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     if(s.length() == n) return s;
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...