# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648622 | lorenzoferrari | Martian DNA (IOI16_dna) | C++17 | 13 ms | 980 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>
using namespace std;
bool make_test(string s);
unordered_map<string, bool> memo;
bool ask(const string& s) {
if (memo.find(s) != memo.end()) {
return memo[s];
} else {
return memo[s] = make_test(s);
}
}
static string nsqrtn(int n, string cur) {
constexpr size_t K = 100;
string prv = cur;
while (cur.size() != n) {
if (ask(cur + "1")) {
cur = prv = cur + "1";
} else {
cur += "0";
}
if (cur.size() - prv.size() > K) {
if (ask(cur)) {
prv = cur;
} else {
break;
}
}
}
while ((int)prv.size() != n && (ask(prv + "0") || ask(prv + "1"))) {
if (ask(prv + "0")) {
prv += "0";
} else {
prv += "1";
}
}
while ((int)prv.size() != n) {
if (ask("0" + prv)) {
prv = "0" + prv;
} else {
prv = "1" + prv;
}
}
return prv;
}
string analyse(int n, int t) {
if (ask(string(200, '0'))) {
return nsqrtn(n, string(200, '0'));
}
int l = 0, r = 200;
while (r - l > 1) {
int m = (l + r) / 2;
if (ask(string(m, '0'))) {
l = m;
} else {
r = m;
}
}
string cur = string(l, '0');
string prv = cur;
while ((int)cur.size() != n && (int)(cur.size() - prv.size()) <= l) {
if (ask(cur + "1")) {
cur = prv = cur + "1";
} else {
cur += "0";
}
}
while (ask(prv + "0")) {
prv += "0";
}
while ((int)prv.size() != n) {
if (ask("0" + prv)) {
prv = "0" + prv;
} else {
prv = "1" + prv;
}
}
return prv;
}
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... |