Submission #143745

#TimeUsernameProblemLanguageResultExecution timeMemory
143745yumCombo (IOI18_combo)C++14
100 / 100
54 ms612 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define ff first #define ss second typedef long long ll; typedef long double ld; typedef pair<int, int> pi; typedef pair<long long, long long> pl; const int MOD = 1e9 + 7; const ll INF = 1e18; const double EPS = 1e-6; string guess_sequence(int N) { vector<char> but = {'A', 'B', 'X', 'Y'}; string ans; if (press("AB") >= 1) ans = press("A") ? "A" : "B"; else ans = press("X") ? "X" : "Y"; but.erase(find(but.begin(), but.end(), ans[0])); for (int i = 1; i < N - 1; ++i) { int res = press(ans + but[0] + ans + but[1] + but[0] + ans + but[1] + but[1] + ans + but[1] + but[2]); if (res == ans.length()) ans += but[2]; else if (res == ans.length() + 1) ans += but[0]; else ans += but[1]; } if (ans.size() == N) return ans; if (press(ans + but[0]) == ans.length() + 1) ans += but[0]; else if (press(ans + but[1]) == ans.length() + 1) ans += but[1]; else ans += but[2]; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   if (res == ans.length()) ans += but[2];
      |       ~~~~^~~~~~~~~~~~~~~
combo.cpp:28:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   else if (res == ans.length() + 1) ans += but[0];
      |            ~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:31:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |  if (ans.size() == N) return ans;
      |      ~~~~~~~~~~~^~~~
combo.cpp:32:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |  if (press(ans + but[0]) == ans.length() + 1) ans += but[0];
      |      ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
combo.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |  else if (press(ans + but[1]) == ans.length() + 1) ans += but[1];
      |           ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...