Submission #939355

#TimeUsernameProblemLanguageResultExecution timeMemory
939355ifateenCombo (IOI18_combo)C++14
0 / 100
0 ms344 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string ans; vector<string> possible = {"A", "B", "X", "Y"}; int idx = -1; for (int i = 0; i < possible.size() - 1; i++) { int ret = press(possible[i]); if (ret == 1) { ans += possible[i]; idx = i; break; } } if (ans.empty()) ans += "Y", idx = 3; swap(possible[idx], possible[3]); while (ans.size() < N) { string query; query += ans; query += possible[1]; query += ans; query += possible[2]; query += possible[0]; query += ans; query += possible[2]; query += possible[1]; query += ans; query += possible[2]; query += possible[2]; int ret_value = press(query); if (ret_value == ans.size()) { // possible[0] ans += possible[0]; } else if (ret_value == ans.size() + 1) { // possible[1] ans += possible[1]; } else ans += possible[2]; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i = 0; i < possible.size() - 1; i++) {
      |                     ~~^~~~~~~~~~~~~~~~~~~~~
combo.cpp:19:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |     while (ans.size() < N) {
      |            ~~~~~~~~~~~^~~
combo.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         if (ret_value == ans.size()) {
      |             ~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:36:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         } else if (ret_value == ans.size() + 1) {
      |                    ~~~~~~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...