Submission #439233

#TimeUsernameProblemLanguageResultExecution timeMemory
439233IdkwhoamiCombo (IOI18_combo)C++17
100 / 100
82 ms644 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; string guess_sequence(int N) { string ans = "Y"; vector<string> all = {"A", "B", "X", "Y"}; int x = press("AB"); if(x >= 1){ if(press("A")==1)ans = "A"; else ans = "B"; } else{ if(press("X") == 1)ans = "X"; else ans = "Y"; } vector<string> possible; for(auto t:all){ if(t != ans)possible.push_back(t); } while(ans.size() != N){ if(ans.size() <= N-2){ string test1 = ans + possible[0] + ans + possible[1] + possible[2] + ans + possible[1] + possible[0] + ans + possible[1] + possible[1]; int x = press(test1); if(x == ans.size()){ ans = ans + possible[2]; } else if(x == ans.size() + 1){ ans = ans + possible[0]; } else{ ans = ans + possible[1]; } } else{ string test1 = ans + possible[0] + ans + possible[1]; int x = press(test1); if(x == ans.size()){ ans = ans + possible[2]; } else{ x = press(ans + possible[0]); if(x == ans.size())ans = ans + possible[1]; else ans = ans + possible[0]; } } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:22: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   26 |     while(ans.size() != N){
      |           ~~~~~~~~~~~^~~~
combo.cpp:28:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   28 |         if(ans.size() <= N-2){
      |            ~~~~~~~~~~~^~~~~~
combo.cpp:32:18: 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(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             else if(x == ans.size() + 1){
      |                     ~~^~~~~~~~~~~~~~~~~
combo.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             if(x == ans.size()){
      |                ~~^~~~~~~~~~~~~
combo.cpp:51:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |                 if(x == ans.size())ans = ans + possible[1];
      |                    ~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...