# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403950 | Iwanttobreakfree | Martian DNA (IOI16_dna) | C++98 | 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 <string>
#include <cstdlib>
#include <set>
using namespace std;
string analyse(int n, int t){
int k=0;
string str,prueba;
bool first=false,posz,poso;
set<string> s;
while(true){
poso=posz=true;
if(str.length()==n)return str;
if(!first){
prueba=str+'0';
int k=prueba.length();
for(string x:s){
int m=x.length();
for(int i=0;i<k-m;i++){
if(substr(i,m)==x){
posz=false;
}
}
}
if(make_test(str+'0')&&posz){
str+='0';
continue;
}
else if(posz)s.insert(str+'0');
prueba=str+'1';
int k=prueba.length();
for(string x:s){
int m=x.length();
for(int i=0;i<k-m;i++){
if(substr(i,m)==x){
poso=false;
}
}
}
if(make_test(str+'1')&&poso){
str+='1';
continue;
}
else if(poso)s.insert(str+'1');
first=true;
}
if(first){
prueba='0'+str;
int k=prueba.length();
for(string x:s){
int m=x.length();
for(int i=0;i<k-m;i++){
if(substr(i,m)==x){
posz=false;
}
}
}
if(make_test('0'+str)&&posz){
str='0'+str;
continue;
}
else if(posz)s.insert('0'+str);
prueba='1'+str;
int k=prueba.length();
for(string x:s){
int m=x.length();
for(int i=0;i<k-m;i++){
if(substr(i,m)==x){
poso=false;
}
}
}
if(make_test('1'+str)&&poso){
str='1'+str;
continue;
}
else if(poso)s.insert('1'+str);
}
}
}