# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091503 | 2024-09-21T03:41:56 Z | rjvkr2021 | Martian DNA (IOI16_dna) | C++17 | 1000 ms | 1072 KB |
#include "dna.h" #include <bits/stdc++.h> using namespace std; #define pb push_back bool is_substring(string &txt, string &pat){ string s = pat + "#" + txt; int n = s.size(); vector<int> pi(n); pi[0] = 0; int l = 0, i = 1; while(i < n){ if(s[i] == s[l]){ l++; pi[i] = l; i++; } else{ if(l == 0){ pi[i] = 0; i++; } else{ l = pi[l - 1]; } } } for(int i = pat.size() + 1; i < n; i++){ if(pi[i] == pat.size()){ return true; } } return false; } string analyse(int n, int t) { vector<string> yes, no; string query; auto valid_query = [&](){ if(query.size() > n){ return false; } for(string &t: yes){ if(!is_substring(query, t)){ return false; } } for(string &t: no){ if(is_substring(query, t)){ return false; } } return true; }; bool response; bool suffix_found = false; while(true){ if(suffix_found){ query.insert(query.begin(), '0'); // try zero if(valid_query()){ response = make_test(query); if(response){ yes.pb(query); continue; } else{ no.pb(query); } } query[0] = '1'; // try one if(valid_query()){ response = make_test(query); if(response){ yes.pb(query); continue; } else{ no.pb(query); } } query.erase(query.begin()); return query; } else{ query.pb('0'); // try zero if(valid_query()){ response = make_test(query); if(response){ yes.pb(query); continue; } else{ no.pb(query); } } query.back() = '1'; // try one if(valid_query()){ response = make_test(query); if(response){ yes.pb(query); continue; } else{ no.pb(query); } } query.pop_back(); suffix_found = true; } } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 0 ms | 344 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 1 ms | 344 KB | Output is correct |
20 | Correct | 1 ms | 600 KB | Output is correct |
21 | Correct | 0 ms | 344 KB | Output is correct |
22 | Correct | 0 ms | 348 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 432 KB | Output is correct |
5 | Correct | 0 ms | 344 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 0 ms | 428 KB | Output is correct |
13 | Correct | 0 ms | 348 KB | Output is correct |
14 | Correct | 0 ms | 344 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 4 ms | 348 KB | Output is correct |
18 | Correct | 4 ms | 348 KB | Output is correct |
19 | Correct | 4 ms | 348 KB | Output is correct |
20 | Correct | 3 ms | 348 KB | Output is correct |
21 | Correct | 4 ms | 468 KB | Output is correct |
22 | Correct | 2 ms | 348 KB | Output is correct |
23 | Correct | 2 ms | 440 KB | Output is correct |
24 | Correct | 2 ms | 348 KB | Output is correct |
25 | Correct | 4 ms | 348 KB | Output is correct |
26 | Correct | 4 ms | 456 KB | Output is correct |
27 | Correct | 2 ms | 348 KB | Output is correct |
28 | Correct | 4 ms | 348 KB | Output is correct |
29 | Correct | 3 ms | 468 KB | Output is correct |
30 | Correct | 3 ms | 348 KB | Output is correct |
31 | Correct | 3 ms | 348 KB | Output is correct |
32 | Correct | 4 ms | 344 KB | Output is correct |
33 | Correct | 4 ms | 464 KB | Output is correct |
34 | Correct | 4 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 440 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 432 KB | Output is correct |
7 | Correct | 0 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 344 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 344 KB | Output is correct |
13 | Correct | 0 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 432 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 3 ms | 348 KB | Output is correct |
18 | Correct | 4 ms | 348 KB | Output is correct |
19 | Correct | 4 ms | 348 KB | Output is correct |
20 | Correct | 3 ms | 348 KB | Output is correct |
21 | Correct | 4 ms | 348 KB | Output is correct |
22 | Execution timed out | 1093 ms | 1072 KB | Time limit exceeded |
23 | Execution timed out | 1063 ms | 776 KB | Time limit exceeded |
24 | Execution timed out | 1025 ms | 848 KB | Time limit exceeded |
25 | Execution timed out | 1049 ms | 656 KB | Time limit exceeded |
26 | Execution timed out | 1045 ms | 780 KB | Time limit exceeded |
27 | Execution timed out | 1031 ms | 848 KB | Time limit exceeded |
28 | Execution timed out | 1063 ms | 1072 KB | Time limit exceeded |
29 | Execution timed out | 1051 ms | 848 KB | Time limit exceeded |
30 | Execution timed out | 1060 ms | 492 KB | Time limit exceeded |
31 | Execution timed out | 1052 ms | 1032 KB | Time limit exceeded |
32 | Execution timed out | 1018 ms | 848 KB | Time limit exceeded |
33 | Execution timed out | 1098 ms | 852 KB | Time limit exceeded |
34 | Execution timed out | 1020 ms | 848 KB | Time limit exceeded |
35 | Execution timed out | 1049 ms | 1012 KB | Time limit exceeded |
36 | Execution timed out | 1058 ms | 852 KB | Time limit exceeded |
37 | Execution timed out | 1082 ms | 876 KB | Time limit exceeded |
38 | Execution timed out | 1020 ms | 848 KB | Time limit exceeded |
39 | Execution timed out | 1059 ms | 764 KB | Time limit exceeded |