Submission #1023037

#TimeUsernameProblemLanguageResultExecution timeMemory
1023037HishamAlshehriCombo (IOI18_combo)C++17
100 / 100
28 ms1672 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string s = ""; string t = "ABXYABXY"; int c = press("AB"); if (c == 2) { s += 'A'; } else if (c == 1) { c = press("A"); if(!c) s += 'B'; else s += 'A'; } else { c = press("Y"); if (c == 1) s += 'Y'; else s += 'X'; } int idx = 0; for (int i = 0; i < 4; i++) if (s[0] == t[i]) {idx = i; break;} char q1 = t[idx + 1], q2 = t[idx + 2], q3 = t[idx + 3]; for (int i = 1; i < N - 1; i++) { c = press(s + q1 + s + q2 + q1 + s + q2 + q2 + s + q2 + q3); if (c == s.size()) s += q3; else if (c == s.size() + 1) s += q1; else s += q2; } if (N - 1) { if (press(s + q1) == N) s += q1; else if (press(s + q2) == N) s += q2; else s += q3; } // cout << s; return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:15: 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 (c == s.size()) s += q3;
      |             ~~^~~~~~~~~~~
combo.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         else if (c == s.size() + 1) s += q1;
      |                  ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...