Submission #1110389

#TimeUsernameProblemLanguageResultExecution timeMemory
1110389SonicMLCombo (IOI18_combo)C++14
100 / 100
51 ms2132 KiB
#include "combo.h" #include <string> using namespace std; string s, all = {'A', 'B', 'X', 'Y'}; char findChar() { if(press(s + "A" + s + "B") == s.size()) { if(press(s +"X") == s.size()) { return 'Y'; } return 'X'; }else { if(press(s + "A") == s.size()) { return 'B'; } return 'A'; } } std::string guess_sequence(int n) { char first = findChar(); s.push_back(first); string choice; for(int i = 0;i < all.size();i++) { if(all[i] != first) { choice.push_back(all[i]); } } for(int i = 2;i < n;i++) { string p; p = s; p.push_back(choice[0]); for(int i = 0;i < choice.size();i++) { p = p + s; p.push_back(choice[1]); p.push_back(choice[i]); } int temp = press(p); if(temp == i) { s.push_back(choice[0]); } else if(temp == i+1) { s.push_back(choice[1]); } else { s.push_back(choice[2]); } } if(n > 1) { s.push_back(findChar()); } return s; }

Compilation message (stderr)

combo.cpp: In function 'char findChar()':
combo.cpp:9:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |   if(press(s + "A" + s + "B") == s.size()) {
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:10:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     if(press(s +"X") == s.size()) {
      |        ~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     if(press(s + "A") == s.size()) {
      |        ~~~~~~~~~~~~~~~^~~~~~~~~~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i = 0;i < all.size();i++) {
      |                 ~~^~~~~~~~~~~~
combo.cpp:36:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for(int i = 0;i < choice.size();i++) {
      |                   ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...