Submission #1004348

#TimeUsernameProblemLanguageResultExecution timeMemory
1004348The_SamuraiCombo (IOI18_combo)C++17
97 / 100
23 ms2012 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string guess_sequence(int n) { string s = "ABXY", ans = ""; if (press("AB") >= 1) { ans = (press("A") ? "A" : "B"); } else { ans = (press("X") ? "X" : "Y"); } s.erase(find(s.begin(), s.end(), ans[0])); for (int i = 1; i < n - 1; i++) { string t = ""; t += ans + s[0]; t += ans + s[1] + s[0]; t += ans + s[1] + s[1]; t += ans + s[1] + s[2]; int shit = press(t); if (shit == ans.size()) ans += s[2]; else if (shit == ans.size() + 1) ans += s[0]; else ans += s[1]; } for (int i = 0; i < 2; i++) { ans += s[i]; if (press(ans) == ans.size()) break; ans.pop_back(); } if (ans.size() != n) ans += s[2]; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if (shit == ans.size()) ans += s[2];
      |             ~~~~~^~~~~~~~~~~~~
combo.cpp:21:23: 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 (shit == ans.size() + 1) ans += s[0];
      |                  ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:26:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         if (press(ans) == ans.size()) break;
      |             ~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:29:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |     if (ans.size() != n) ans += s[2];
      |         ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...