Submission #726547

#TimeUsernameProblemLanguageResultExecution timeMemory
726547horiseunCombo (IOI18_combo)C++11
5 / 100
1 ms280 KiB
#include "combo.h" #include <vector> #include <cstring> using namespace std; string guess_sequence(int n) { vector<char> letters = {'A', 'B', 'X', 'Y'}; string ans = ""; for (int i = 0; i < 4; i++) { ans += letters[i]; if (press(ans) > 0) { letters.erase(letters.begin() + i); break; } ans.pop_back(); } while (ans.length() <= n - 2) { string gs = ans + letters[0] + ans + letters[1] + letters[0] + ans + letters[1] + letters[1] + ans + letters[1] + letters[2]; int temp = press(gs); if (temp == ans.size() + 1) { ans += letters[0]; } else if (temp == ans.size() + 2) { ans += letters[1]; } else { ans += letters[2]; } } for (int i = 0; i < 3; i++) { ans += letters[i]; if (press(ans) == n) { break; } ans.pop_back(); } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:18:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   18 |     while (ans.length() <= n - 2) {
      |            ~~~~~~~~~~~~~^~~~~~~~
combo.cpp:21:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         if (temp == ans.size() + 1) {
      |             ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:23:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         } else if (temp == ans.size() + 2) {
      |                    ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...