# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1091502 | rjvkr2021 | Martian DNA (IOI16_dna) | C++17 | 0 ms | 0 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 "dna.h"
#include <bits/stdc++.h>
using namespace std;
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;
}
}
}