Submission #715838

#TimeUsernameProblemLanguageResultExecution timeMemory
715838TheSahibCombo (IOI18_combo)C++17
100 / 100
36 ms604 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { vector<char> v = {'A', 'B', 'X', 'Y'}; string s = ""; if(press("AB")){ if(press("A")) s = "A"; else s = "B"; } else{ if(press("X")) s = "X"; else s = "Y"; } v.erase(find(v.begin(), v.end(), s[0])); if(N == 1) return s; while(s.size() < N - 1){ string a = s + v[0]; for(int i = 0; i < 3; i++){ a += s + v[1] + v[i]; } int ans = press(a); if(ans == s.size()){ s.push_back(v[2]); } else if(ans == s.size() + 1){ s.push_back(v[0]); } else{ s.push_back(v[1]); } } if(press(s + v[0]) == s.size() + 1){ s.push_back(v[0]); } else if(press(s + v[1]) == s.size() + 1){ s.push_back(v[1]); } else{ s.push_back(v[2]); } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     while(s.size() < N - 1){
      |           ~~~~~~~~~^~~~~~~
combo.cpp:26:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if(ans == s.size()){
      |            ~~~~^~~~~~~~~~~
combo.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         else if(ans == s.size() + 1){
      |                 ~~~~^~~~~~~~~~~~~~~
combo.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     if(press(s + v[0]) == s.size() + 1){
      |        ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:39:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     else if(press(s + v[1]) == s.size() + 1){
      |             ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...