Submission #1039117

#TimeUsernameProblemLanguageResultExecution timeMemory
1039117VMaksimoski008Combo (IOI18_combo)C++17
100 / 100
19 ms1384 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string S = ""; if(press("XY")) { if(press("X")) S += 'X'; else S += 'Y'; } else if(press("A")) { S += 'A'; } else { S += 'B'; } vector<char> vec; for(auto &ch : {'A', 'B', 'X', 'Y'}) if(ch != S[0]) vec.push_back(ch); //press(p) dava dolzina na najdolg prefix na S sto e substring na p while(S.size() + 1 < N) { int len = press(S + vec[0] + vec[0] + S + vec[0] + vec[1] + S + vec[1] + vec[0]); if(len == S.size()) { S += vec[2]; } else if(len == S.size() + 1) { int x = press(S + vec[1] + vec[2]); if(x == S.size() + 2) { S += vec[1]; S += vec[2]; } else if(x == S.size() + 1) { S += vec[1]; S += vec[1]; } else { S += vec[0]; S += vec[2]; } } else { int x = press(S + vec[0] + vec[0]); if(x == S.size() + 2) { S += vec[0]; S += vec[0]; } else if(x == S.size() + 1) { S += vec[0]; S += vec[1]; } else { S += vec[1]; S += vec[0]; } } } if(S.size() < N) { if(press(S + vec[0]) == S.size() + 1) S += vec[0]; else if(press(S + vec[1]) == S.size() + 1) S += vec[1]; else S += vec[2]; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:22:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |     while(S.size() + 1 < N) {
      |           ~~~~~~~~~~~~~^~~
combo.cpp:24:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if(len == S.size()) {
      |            ~~~~^~~~~~~~~~~
combo.cpp:26:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         } else if(len == S.size() + 1) {
      |                   ~~~~^~~~~~~~~~~~~~~
combo.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             if(x == S.size() + 2) {
      |                ~~^~~~~~~~~~~~~~~
combo.cpp:31:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |             } else if(x == S.size() + 1) {
      |                       ~~^~~~~~~~~~~~~~~
combo.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |             if(x == S.size() + 2) {
      |                ~~^~~~~~~~~~~~~~~
combo.cpp:43:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             } else if(x == S.size() + 1) {
      |                       ~~^~~~~~~~~~~~~~~
combo.cpp:53:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   53 |     if(S.size() < N) {
      |        ~~~~~~~~~^~~
combo.cpp:54:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |         if(press(S + vec[0]) == S.size() + 1) S += vec[0];
      |            ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:55:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |         else if(press(S + vec[1]) == S.size() + 1) S += vec[1];
      |                 ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...