# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
648622 | 2022-10-07T07:57:26 Z | lorenzoferrari | Martian DNA (IOI16_dna) | C++17 | 13 ms | 980 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 292 KB | Output is correct |
2 | Correct | 1 ms | 296 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 296 KB | Output is correct |
5 | Correct | 0 ms | 304 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 300 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 300 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 232 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 296 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 0 ms | 296 KB | Output is correct |
7 | Correct | 1 ms | 300 KB | Output is correct |
8 | Correct | 0 ms | 304 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 304 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 308 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 412 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 340 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 300 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
29 | Correct | 1 ms | 340 KB | Output is correct |
30 | Correct | 1 ms | 308 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 1 ms | 212 KB | Output is correct |
33 | Correct | 1 ms | 296 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 296 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 300 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 300 KB | Output is correct |
18 | Correct | 1 ms | 300 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 1 ms | 296 KB | Output is correct |
22 | Correct | 10 ms | 944 KB | Output is correct |
23 | Correct | 11 ms | 852 KB | Output is correct |
24 | Correct | 10 ms | 956 KB | Output is correct |
25 | Correct | 13 ms | 980 KB | Output is correct |
26 | Correct | 12 ms | 980 KB | Output is correct |
27 | Correct | 7 ms | 940 KB | Output is correct |
28 | Correct | 8 ms | 980 KB | Output is correct |
29 | Correct | 9 ms | 980 KB | Output is correct |
30 | Correct | 7 ms | 852 KB | Output is correct |
31 | Correct | 6 ms | 852 KB | Output is correct |
32 | Correct | 9 ms | 980 KB | Output is correct |
33 | Correct | 9 ms | 852 KB | Output is correct |
34 | Correct | 9 ms | 924 KB | Output is correct |
35 | Correct | 9 ms | 852 KB | Output is correct |
36 | Correct | 9 ms | 980 KB | Output is correct |
37 | Correct | 7 ms | 852 KB | Output is correct |
38 | Correct | 9 ms | 980 KB | Output is correct |
39 | Correct | 11 ms | 980 KB | Output is correct |