Submission #497242

#TimeUsernameProblemLanguageResultExecution timeMemory
497242pakhomoveeCombo (IOI18_combo)C++17
97 / 100
28 ms552 KiB
#include "combo.h" #include <vector> #include <algorithm> #include <cassert> using namespace std; int press(string p); string guess_sequence(int N) { vector<char> v = { 'A', 'B', 'X', 'Y' }; string res; for (int i = 0; i < 3; ++i) { string curr; curr += v[i]; if (press(curr)) { res += v[i]; break; } } if (res.size() == 0) { res += 'Y'; } v.erase(find(v.begin(), v.end(), res[0])); int ptr = 1; while (ptr + 1 < N) { string query = res; query += v[0]; query += res; query += v[1]; query += v[0]; query += res; query += v[1]; query += v[1]; query += res; query += v[1]; query += v[2]; assert(query.size() <= N * 4); int c = press(query); if (c == ptr) { res += v[2]; } else if (c == ptr + 1) { res += v[0]; } else { res += v[1]; } ++ptr; } if (ptr < N) { for (int i = 0; i < 2; ++i) { string curr = res; curr += v[i]; if (press(curr) == N) { res += v[i]; break; } } if (res.size() < N) { res += v[2]; } } v = { 'A', 'B', 'X', 'Y' }; return res; }

Compilation message (stderr)

In file included from /usr/include/c++/10/cassert:44,
                 from combo.cpp:4:
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:38:29: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   38 |         assert(query.size() <= N * 4);
      |                ~~~~~~~~~~~~~^~~~~~~~
combo.cpp:58:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |         if (res.size() < N) {
      |             ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...