Submission #864873

#TimeUsernameProblemLanguageResultExecution timeMemory
864873n1kCombo (IOI18_combo)C++17
100 / 100
14 ms2076 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; /* XYYABYABAY */ std::string guess_sequence(int N) { // find first char // in one op string guess = "AB", s = ""; if(press(guess)){ s = press("A") ? "A" : "B"; }else{ s = press("X") ? "X" : "Y"; } if(N == 1){ return s; } vector<string> vorrat = {"A", "B", "X", "Y"}; vorrat.erase(find(vorrat.begin(), vorrat.end(), s)); // guess next char while(s.size() < N - 1){ guess = s + vorrat[0]; for(auto x: vorrat){ guess += s + vorrat[1] + x; } int c = press(guess); if(c == s.size() + 1){ s += vorrat[0]; }else if(c == s.size() + 2){ s += vorrat[1]; }else{ s += vorrat[2]; } } if(s.size() < press(s + vorrat[0])){ s += vorrat[0]; }else if(s.size() < press(s + vorrat[1])){ s += vorrat[1]; }else{ s += vorrat[2]; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:29:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |  while(s.size() < N - 1){
      |        ~~~~~~~~~^~~~~~~
combo.cpp:35:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |   if(c == s.size() + 1){
      |      ~~^~~~~~~~~~~~~~~
combo.cpp:37:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   }else if(c == s.size() + 2){
      |            ~~^~~~~~~~~~~~~~~
combo.cpp:44:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |  if(s.size() < press(s + vorrat[0])){
      |     ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
combo.cpp:46:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |  }else if(s.size() < press(s + vorrat[1])){
      |           ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...