Submission #650006

#TimeUsernameProblemLanguageResultExecution timeMemory
650006tvladm2009Combo (IOI18_combo)C++14
100 / 100
48 ms564 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string brute(string s) { if (press(s + "A" + s + "B") > s.size()) { if (press(s + "A") > s.size()) { return s + "A"; } else { return s + "B"; } } else { if (press(s + "X") > s.size()) { return s + "X"; } else { return s + "Y"; } } } string smart(string s) { vector<char> kek(3); if (s[0] == 'A') { kek[0] = 'B'; kek[1] = 'X'; kek[2] = 'Y'; } else if (s[0] == 'B') { kek[0] = 'A'; kek[1] = 'X'; kek[2] = 'Y'; } else if (s[0] == 'X') { kek[0] = 'A'; kek[1] = 'B'; kek[2] = 'Y'; } else { kek[0] = 'A'; kek[1] = 'B'; kek[2] = 'X'; } string test = s + kek[1] + s + kek[2] + kek[0] + s + kek[2] + kek[1] + s + kek[2] + kek[2]; int p = press(test); if (p == s.size()) { return s + kek[0]; } else if (p == s.size() + 1) { return s + kek[1]; } else { return s + kek[2]; } } string guess_sequence(int n) { string ans; ans = brute(ans); for (int i = 2; i < n; i++) { ans = smart(ans); } if (n > 1) { ans = brute(ans); } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string brute(std::string)':
combo.cpp:7:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |   if (press(s + "A" + s + "B") > s.size()) {
      |       ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:8:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     if (press(s + "A") > s.size()) {
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp:14:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     if (press(s + "X") > s.size()) {
      |         ~~~~~~~~~~~~~~~^~~~~~~~~~
combo.cpp: In function 'std::string smart(std::string)':
combo.cpp:44:9: 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 (p == s.size()) {
      |       ~~^~~~~~~~~~~
combo.cpp:46:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   } else if (p == s.size() + 1) {
      |              ~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...