Submission #107246

#TimeUsernameProblemLanguageResultExecution timeMemory
107246wonyoungCombo (IOI18_combo)C++14
30 / 100
117 ms712 KiB
#include <vector> #include <string> using namespace std; int press(string p); string guess_sequence(int N) { vector<char> buttons = { 'A', 'B', 'X', 'Y' }; string prefix; char first_char; int n; n = press("AB"); if (n == 2) { prefix = "AB"; buttons.erase(buttons.begin()); } else if (n == 1) { if (press("A") > 0) { prefix = "A"; buttons.erase(buttons.begin()); } else { prefix = "B"; buttons.erase(buttons.begin()+1); } } else { if (press("X") > 0) { prefix = "X"; buttons.erase(buttons.begin()+2); } else { prefix = "Y"; buttons.erase(buttons.begin()+3); } } int i; while (prefix.length() < N) { for (i=0; i< 2; i++) { string query_string = ""; string s = prefix; s.push_back(buttons[i]); query_string += s; while (query_string.length() + s.length() + 1 < N * 4) { s.push_back(buttons[0]); query_string += s; } n = press(query_string); if (n > prefix.length()) { break; } } prefix.push_back(buttons[i]); for (int i=prefix.length(); i<n; i++) { prefix.push_back(buttons[0]); } } return prefix; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:28: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     while (prefix.length() < N)
      |            ~~~~~~~~~~~~~~~~^~~
combo.cpp:55:59: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   55 |             while (query_string.length() + s.length() + 1 < N * 4)
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
combo.cpp:61:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             if (n > prefix.length())
      |                 ~~^~~~~~~~~~~~~~~~~
combo.cpp:10:10: warning: unused variable 'first_char' [-Wunused-variable]
   10 |     char first_char;
      |          ^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...