Submission #749629

#TimeUsernameProblemLanguageResultExecution timeMemory
749629tamyteCombo (IOI18_combo)C++14
5 / 100
1 ms236 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; const string code = "ABXYY"; // int press(string s) { // int ans = 0; // // cerr << "a"; // for (int i = 0; i < s.size();) { // int j = i, ptr = 0; // while (j < s.size() && code[ptr] == s[j]) { // j++; ptr++; // } // i = max(j, i + 1); // // cerr << s << " " << ptr << "\n"; // ans = max(ans, ptr); // } // return ans; // } string guess_sequence(int N) { vector<string> el = {"A", "B", "X", "Y"}; string ans = ""; if (press(el[0])) { ans += el[0]; } else if (press(el[1])) { ans += el[1]; } else if (press(el[2])) { ans += el[2]; } else { ans += el[3]; } vector<char> fin; for (auto u : el) { if (ans[0] != u[0]) { fin.push_back(u[0]); } } for (int i = 1; i <= N; ++i) { string guess = ans + fin[0] + fin[0] + ans + fin[0] + fin[1] + ans + fin[0] + fin[2]; if (press(guess) == ans.size()) { guess = ans + fin[1] + fin[1] + ans + fin[1] + fin[2]; if (press(guess) == ans.size()) { ans += fin[2]; } else { ans += fin[1]; } } else { ans += fin[0]; } if (ans.size() == N) return ans; } return ans; } // int main () { // cout << guess_sequence(code.size()); // }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         if (press(guess) == ans.size()) {
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:44:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if (press(guess) == ans.size()) {
      |                 ~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:52:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   52 |         if (ans.size() == N) return ans;
      |             ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...