# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
329481 | mihai145 | Martian DNA (IOI16_dna) | C++14 | 15 ms | 492 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 <cstdlib>
#include <random>
int failureCt = 19;
std::string analyse(int n, int t) {
std::string randomSuffix = "";
int failures = 0;
while(failures < failureCt && randomSuffix.size() < n) {
int rnd = rand() % 2;
if(rnd == 0) {
bool res = make_test(randomSuffix + '0');
if(res == true) {
randomSuffix += '0';
failures = 0;
} else {
randomSuffix += '1';
failures++;
}
} else {
bool res = make_test(randomSuffix + '1');
if(res == true) {
randomSuffix += '1';
failures = 0;
} else {
randomSuffix += '0';
failures++;
}
}
}
std::string root = "", rnd = "";
for(int i = 0; i < (int)randomSuffix.size(); i++) {
if(i + failures >= (int)randomSuffix.size()) {
rnd += randomSuffix[i];
} else {
root += randomSuffix[i];
}
}
int st = 0, dr = (int)rnd.size(), sol = 0;
while(st <= dr) {
int mid = (st + dr) >> 1;
std::string toQ = root;
for(int i = 0; i < mid; i++)
toQ += rnd[i];
bool res = make_test(toQ);
if(res == true) {
sol = mid;
st = mid + 1;
} else {
dr = mid - 1;
}
}
for(int i = 0; i < sol; i++)
root += rnd[i];
while((int)root.size() < n) {
bool res = make_test('0' + root);
if(res == true) {
root = '0' + root;
} else {
root = '1' + root;
}
}
return root;
}
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... |