Submission #228374

#TimeUsernameProblemLanguageResultExecution timeMemory
228374hhh07Combo (IOI18_combo)C++14
10 / 100
183 ms720 KiB
#include <iostream> #include <vector> #include <algorithm> #include "combo.h" using namespace std; string napravi(string curr, char x, int n){ /*string res = ""; int j = 0; for (int i = 0; i < n; i++){ if (j < curr.length()){ res += curr[j]; j++; } else{ res += x; j = 0; } } return res;*/ return (string)(curr + x); } string rez(string s, int x){ string y = ""; for (int i = 0; i < x; i++) y += s[i]; return y; } string maks(string a, string b, string x, string y){ if (a.length() > b.length() && a.length() > x.length() && a.length() > y.length()) return a; if (b.length() > a.length() && b.length() > x.length() && b.length() > y.length()) return b; if (x.length() > a.length() && x.length() > y.length() && x.length() > b.length()) return x; return y; } string guess_sequence(int n){ string curr = ""; while(curr.length() < n){ string a = rez(napravi(curr, 'A', curr.length() + 1), press(napravi(curr, 'A', curr.length() + 1))); string x = rez(napravi(curr, 'X', curr.length() + 1), press(napravi(curr, 'X', curr.length() + 1))); string y = rez(napravi(curr, 'Y', curr.length() + 1), press(napravi(curr, 'Y', curr.length() + 1))); string b = rez(napravi(curr, 'B', curr.length() + 1), press(napravi(curr, 'B', curr.length() + 1))); curr = maks(a, b, x, y); } return curr; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:25: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   45 |     while(curr.length() < n){
      |           ~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...