# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
406482 | Alma | Martian DNA (IOI16_dna) | C++17 | 1098 ms | 328 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 analyse(int n, int t) {
string p = "";
int max_0 = 0, max_1 = 0;
int lo = 0, mid, hi = n;
while (lo <= hi) {
mid = (lo + hi) / 2;
p = '0' * mid;
if (make_test(p)) {
lo = max_0 = mid;
} else {
hi = mid;
}
}
lo = 0; hi = n;
while (lo <= hi) {
mid = (lo + hi) / 2;
p = '1' * mid;
if (make_test(p)) {
max_1 = mid;
lo = mid+1;
} else {
hi = mid-1;
}
}
bool zero, one;
int num_0 = 0, num_1 = 0;
p = "";
while ((int)p.size() < n) {
if (num_0 < max_0) zero = make_test(p + '0');
if (num_0 < max_0 && zero) {
p += '0';
num_0++; num_1 = 0;
continue;
}
if (num_1 < max_1) one = make_test(p + '1');
if (num_1 < max_1 && one) {
p += '1';
num_1++; num_0 = 0;
continue;
}
break;
}
if ((int)p.size() == n) return p;
while ((int)p.size() < n) {
zero = make_test('0' + p);
if (zero) {
p = '0' + p;
continue;
}
p = '1' + p;
}
return p;
}
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... |