Submission #766930

#TimeUsernameProblemLanguageResultExecution timeMemory
766930turtlemodeCombo (IOI18_combo)C++14
100 / 100
22 ms520 KiB
#include "combo.h" #include <set> #include <vector> #include <iostream> using namespace std; std::string guess_sequence(int N) { if (N == 0){ return ""; } std::string S = ""; if (press("AB")){ if (press("A")){ S += "A"; } else{ S += "B"; } } else { if (press("X")){ S += "X"; } else{ S += "Y"; } } if (N == 1){ return S; } set<string> all_chars {"A", "B", "X", "Y"}; all_chars.erase(S); vector<string> legal_chars; set<string>::iterator k; for (k = all_chars.begin(); k != all_chars.end(); ++k) legal_chars.push_back(*k); //cout << "Current: " << S << endl; while (S.length() < N - 1){ // int coins = press(S + "B" + S + "XB" + S + "XX" + S + "XY"); int coins = press(S + legal_chars[0] + S + legal_chars[1] + legal_chars[0] + S + legal_chars[1] + legal_chars[1] + S + legal_chars[1] + legal_chars[2]); if (coins == S.length() + 1){ S += legal_chars[0]; } else if (coins == S.length() + 2){ S += legal_chars[1]; } else if (coins == S.length() + 0){ S += legal_chars[2]; } else { //cout << "Wuut" << endl; } //cout << "Current: " << S << endl; } if (press(S + legal_chars[0]) == S.length() + 1){ return S + legal_chars[0]; } if (press(S + legal_chars[1]) == S.length() + 1){ return S + legal_chars[1]; } else{ return S + legal_chars[2]; } //cout << "Wuuut2" << endl; return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |   while (S.length() < N - 1){
      |          ~~~~~~~~~~~^~~~~~~
combo.cpp:41:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     if (coins == S.length() + 1){
      |         ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     else if (coins == S.length() + 2){
      |              ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:47:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     else if (coins == S.length() + 0){
      |              ~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:57:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   if (press(S + legal_chars[0]) == S.length() + 1){
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:60:33: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |   if (press(S + legal_chars[1]) == S.length() + 1){
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...