# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
228369 | hhh07 | Combo (IOI18_combo) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
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', n), press(napravi(curr, 'A', n)));
string x = rez(napravi(curr, 'X', n), press(napravi(curr, 'X', n)));
string y = rez(napravi(curr, 'Y', n), press(napravi(curr, 'Y', n)));
string b = rez(napravi(curr, 'B', n), press(napravi(curr, 'B', n)));
curr = maks(a, b, x, y);
}
return curr;
}