Submission #939399

#TimeUsernameProblemLanguageResultExecution timeMemory
939399ifateenCombo (IOI18_combo)C++14
100 / 100
15 ms1772 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"}; // A if (press("AB")) { if (press("A")) ans += 'A', possible = {"B", "X", "Y", "A"}; else ans += 'B', possible = {"A", "X", "Y", "B"}; } else { if (press("X")) ans += 'X', possible = {"A", "B", "Y", "X"}; else ans += 'Y'; } while (ans.size() < N - 1) { string query = ans + possible[1] + ans + possible[2] + possible[0] + ans + possible[2] + possible[1] + ans + possible[2] + possible[2]; int ret = press(query); if (ret == ans.size()) { ans += possible[0]; } else if (ret == ans.size() + 1) { ans += possible[1]; } else { ans += possible[2]; } } if (ans.size() == N) return ans; int zero = press(ans + possible[0]); if (zero == N) return (ans += possible[0]); int one = press(ans + possible[1]); if (one == N) return (ans += possible[1]); return (ans += possible[2]); }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:16:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   16 |     while (ans.size() < N - 1) {
      |            ~~~~~~~~~~~^~~~~~~
combo.cpp:19:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         if (ret == ans.size()) {
      |             ~~~~^~~~~~~~~~~~~
combo.cpp:21:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         } else if (ret == ans.size() + 1) {
      |                    ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:27:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |     if (ans.size() == N) return ans;
      |         ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...