# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
882290 | pirhosig | Martian DNA (IOI16_dna) | C++17 | 10 ms | 608 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 analyse(int n, int t)
{
string res;
if (n < 500)
{
bool forward = true;
for (int i = 0; i < n; ++i)
{
if (forward)
{
if (make_test(res + '0')) res += '0';
else if (make_test(res + '1')) res += '1';
else forward = false;
}
if (!forward)
{
res.insert(0, 1, '0');
if (!make_test(res)) res[0] = '1';
}
}
}
else
{
int len = 0;
int val = 0;
while (val < n) {
if (rand() % 2) {
res.append("0");
if (make_test(res)) len = val;
else res.back() = '1';
}
else {
res.append("1");
if (make_test(res)) len = val;
else res.back() = '0';
}
val++;
if (val - len == 11) {
bool full = true;
while (len < val) {
int mid = (len + val + 1) / 2;
if (make_test(res.substr(0, mid))) len = mid;
else {
for (int i = 0; i <= val - mid; ++i) res.pop_back();
val = mid - 1;
goto end;
}
}
}
}
end:
while (len < val) {
int mid = (len + val + 1) / 2;
if (make_test(res.substr(0, mid))) len = mid;
else {
for (int i = 0; i <= val - mid; ++i) res.pop_back();
val = mid - 1;
}
}
while (len < n) {
res.insert(0, 1, '0');
if (!make_test(res)) res[0] = '1';
len++;
}
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |