# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
33862 | wan2000 | Martian DNA (IOI16_dna) | C++14 | 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){
string res = "";
int l = 1, r = n, mid;
int cur = 0;
while(l<=r){
mid = (l+r)>>1;
if(make_test(add("",mid,'1'))){
cur = mid;
l = mid+1;
}
else r = mid-1;
}
res = add("",cur,'1');
string tmp = res;
int cnt = 0;
while(tmp.size()<n){
if(make_test(tmp+"0")){
tmp += "0";
cnt = 0;
}
else{
tmp += "1";
cnt++;
}
if(cnt>cur) break;
}
l = tmp.size()-cnt+1; r = tmp.size();
int suf = tmp.size()-cnt;
while(l<=r){
mid = (l+r)>>1;
string s = "";
for(int i = 0; i < mid; i++){
s += tmp[i];
}
if(make_test(s)){
suf = mid;
l = mid+1;
}
else r = mid-1;
}
res = "";
for(int i = 0; i < suf; i++) res += tmp[i];
while(res.size()<n){
if(make_test("0"+res)) res = "0"+res;
else res = "1"+res;
}
return res;
}