# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
561907 | tj14 | Martian DNA (IOI16_dna) | 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 "dna.h"
#include <bits/stdc++.h>
using namespace std;
string get_repeat_char(string x, int rep) {
string s = "";
for (int i = 0; i < rep; i++)
s += x;
return s;
}
string analyse(int n, int t) {
int l = 1, r = n;
while (l <= r) {
int m = (l + r) / 2;
if (make_test(get_repeat_char("0", m)))
l = m + 1;
else
r = m - 1;
}
int longest_zeros = r;
int c = 0;
string primer = get_repeat_char("0", longest_zeros);
string almost_suffix;
while (c < longest_zeros) {
if (make_test(primer + "1")) {
primer += "1";
almost_suffix = primer;
c = 0;
} else {
primer += "0";
c++;
}
}
l = 1, r = c;
while (l <= r) {
int m = (l + r) / 2;
if (make_test(almost_suffix + get_repeat_char("0", m)))
l = m + 1;
else
r = m - 1;
}
string suffix = almost_suffix + get_repeat_char("0", r);
while (suffix.length <= n) {
if (make_test("1" + suffix))
suffix = "1" + suffix;
else
suffix = "0" + suffix;
}
return suffix;
}