| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 595769 | jophyyjh | Martian DNA (IOI16_dna) | C++14 | 13 ms | 456 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.
/**
* OK, so we have a binary str of len n. Each time we're allowed to give a str and
* whether the str is a substr of the original binary str is returned. The task is
* to determine the entire str under a certain num of interactions.
*
* Well it looks to me that the num of steps shall be O(n). Well, i think i've got
* a solution by extending the current str on either side. 2n steps is now the
* maximum.
*
* We want to further lower the num of interactions. Can we directly determine the
* first char? Well i guess the goal is to find the suffix (or equivalently the
* prefix). In the algo above, we extend our str on the right side until it can
* no longer be extended; after this, we can just extend it on the left side,
* without fearing that a "true" response corresponds to a substr which is not a
* suffix (shifted pos). In other words, we wish to find a substr such that:
* make_test((substr)0), make_test((substr)1) are all false.
*
* Number of steps: 2n
* Implementation 1
*/
#include <bits/stdc++.h>
#include "dna.h"
std::string analyse(int n, int T) {
std::string current = "";
for (;;) {
bool one = make_test(current + "1");
if (one) {
current.push_back('1');
continue;
}
bool zero = make_test(current + "0");
if (zero) {
current.push_back('0');
continue;
}
// can't append any char (at the back)
break;
}
assert(int(current.size()) <= n);
while (int(current.size()) < n) {
if (make_test("0" + current))
current.insert(0, 1, '0');
else
current.insert(0, 1, '1');
}
return current;
}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... | ||||
