Submission #107628

#TimeUsernameProblemLanguageResultExecution timeMemory
107628FiloSanzaCombo (IOI18_combo)C++14
100 / 100
59 ms708 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { vector<string> v = {"A", "B", "X", "Y"}; random_shuffle(v.begin(), v.end()); string sol = ""; //First char if(press(v[0]+v[1])){ if(press(v[0])) sol = v[0]; else sol = v[1]; } else{ if(press(v[2])) sol = v[2]; else sol = v[3]; } v.erase(find(v.begin(), v.end(), sol)); if(N == 1) return sol; string tmp; while(true){ if(sol.size() == N-1){ if(press(sol+v[0]) == N) return sol+v[0]; if(press(sol+v[1]) == N) return sol+v[1]; return sol+v[2]; } tmp = (sol + v[0]) + (sol + v[1] + v[2]) + (sol + v[1] + v[0]) + (sol + v[1] + v[1]); assert(tmp.size() <= 4*N); int coins = press(tmp); if(coins == sol.size() + 1) sol += v[0]; else if(coins == sol.size() + 2) sol += v[1]; else sol += v[2]; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |         if(sol.size() == N-1){
      |            ~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:2:
combo.cpp:34:27: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         assert(tmp.size() <= 4*N);
      |                ~~~~~~~~~~~^~~~~~
combo.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if(coins == sol.size() + 1) sol += v[0];
      |            ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         else if(coins == sol.size() + 2) sol += v[1];
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...