# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
159265 | 2019-10-21T18:31:51 Z | Leonardo_Paes | Martian DNA (IOI16_dna) | C++14 | 16 ms | 504 KB |
#include "dna.h" #include <cstdlib> #include <bits/stdc++.h> using namespace std; bool check1(int x){ string s; s.resize(x); for(int i=0; i<x; i++) s[i] = '1'; return make_test(s); } bool check2(int x, string aux){ string s; s.resize(x); for(int i=0; i<x; i++) s[i] = aux[i]; return make_test(s); } string analyse(int n, int t){ if(!make_test("1")){ string a; a.resize(n); for(int i=0; i<n; i++) a[i] = '0'; return a; } int ini = 0, fim = n, meio, longest1 = 0; while(ini <= fim){ meio = (ini + fim) >> 1; if(check1(meio)){ longest1 = meio; ini = meio + 1; } else{ fim = meio-1; } } string s; for(int i=0; i<longest1; i++) s += '1'; int consec1 = longest1; while(consec1<=longest1){ string aux = s; aux += '0'; if(make_test(aux)){ s += '0'; consec1 = 0; } else{ s += '1'; consec1++; } } ini = (int)s.size() - consec1, fim = (int)s.size(); int idend; while(ini <= fim){ meio = (ini + fim ) >> 1; if(check2(meio, s)){ idend = meio; ini = meio + 1; } else{ fim = meio - 1; } } deque<char> ans; for(int i=0; i<idend; i++) ans.push_back(s[i]); while(ans.size() < n){ ans.push_front('1'); string aux; aux.resize((int)ans.size()); for(int i=0; i<ans.size(); i++) aux[i] = ans[i]; if(!make_test(aux)){ ans.pop_front(); ans.push_front('0'); } } string true_ans; true_ans.resize(n); for(int i=0; i<ans.size(); i++) true_ans[i] = ans[i]; return true_ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 252 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 252 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 392 KB | Output is correct |
21 | Correct | 2 ms | 256 KB | Output is correct |
22 | Correct | 2 ms | 256 KB | Output is correct |
23 | Correct | 2 ms | 256 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 2 ms | 376 KB | Output is correct |
26 | Correct | 2 ms | 376 KB | Output is correct |
27 | Correct | 2 ms | 376 KB | Output is correct |
28 | Correct | 2 ms | 256 KB | Output is correct |
29 | Correct | 2 ms | 256 KB | Output is correct |
30 | Correct | 2 ms | 256 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 376 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 376 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 256 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 13 ms | 248 KB | Output is correct |
23 | Correct | 16 ms | 504 KB | Output is correct |
24 | Correct | 16 ms | 376 KB | Output is correct |
25 | Correct | 16 ms | 376 KB | Output is correct |
26 | Correct | 13 ms | 376 KB | Output is correct |
27 | Correct | 9 ms | 376 KB | Output is correct |
28 | Correct | 9 ms | 376 KB | Output is correct |
29 | Correct | 2 ms | 376 KB | Output is correct |
30 | Correct | 2 ms | 376 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 8 ms | 376 KB | Output is correct |
33 | Correct | 12 ms | 376 KB | Output is correct |
34 | Correct | 13 ms | 376 KB | Output is correct |
35 | Correct | 11 ms | 376 KB | Output is correct |
36 | Correct | 12 ms | 376 KB | Output is correct |
37 | Correct | 12 ms | 376 KB | Output is correct |
38 | Correct | 9 ms | 376 KB | Output is correct |
39 | Correct | 13 ms | 376 KB | Output is correct |