# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
775328 | anha3k25cvp | Martian DNA (IOI16_dna) | C++14 | 13 ms | 412 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 <bits/stdc++.h>
#include "dna.h"
using namespace std;
string del(string S, int len) {
string T;
for (int i = 0; i + len < S.size(); i ++)
T += S[i];
return T;
}
string analyse(int n, int t) {
int lo = 0, hi = n;
while (lo < hi) {
int mid = (lo + hi + 1) / 2;
string S;
for (int i = 1; i <= mid; i ++)
S += '0';
int val = make_test(S);
if (val)
lo = mid;
else
hi = mid - 1;
}
string ans;
for (int i = 1; i <= lo; i ++)
ans += '0';
int check = 1, l = lo, cnt = lo;
while (n) {
if (check) {
string S = ans;
S += '1';
int add_right = make_test(S);
if (!add_right) {
if (cnt < l) {
ans += '0';
cnt ++;
n --;
continue;
}
lo = 0; hi = l;
while (lo < hi) {
int mid = (lo + hi) / 2;
S = del(ans, mid);
int val = make_test(S);
if (val)
hi = mid;
else
lo = mid + 1;
}
ans = del(ans, lo);
n += lo;
check = 0;
}
else {
ans += '1';
n --;
cnt = 0;
}
}
else {
n --;
string S = "1";
S += ans;
int add_left = make_test(S);
if (add_left)
ans = '1' + ans;
else
ans = '0' + ans;
}
}
return ans;
}
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... |