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;
int bsearch1(int n)
{
int ini = 1, fim = n, mid, best;
while(fim >= ini)
{
mid = (ini + fim)/2;
string aux;
for(int i = 1; i <= mid; i++) aux += "0";
if(make_test(aux)) best = mid, ini = mid + 1;
else fim = mid - 1;
}
return best;
}
string analyse(int n, int t)
{
string ans, S, resp;
int mz = bsearch1(n);
for(int i = 0; i < mz; i++) ans += "0";
for(int i = 1; i <= n - mz; i++)
{
if(make_test(ans + "1")) ans += "1";
else
{
int qtdz = 0;
for(int j = ans.size() - 1; j >= 0; j--)
{
if(ans[j] != '0') break;
qtdz ++;
}
if(qtdz > mz) break;
ans += "0";
}
}
int ini = mz - 1, fim = n - 1, mid, best;
while(fim >= ini)
{
mid = (ini + fim)/2;
string aux;
for(int i = 0; i <= mid; i++) aux += ans[i];
if(make_test(aux)) best = mid, ini = mid + 1;
else fim = mid - 1;
}
for(int i = 0; i <= best; i++) S += ans[i];
for(int resta = 1; resta < n - best; resta ++)
{
if(make_test("1" + S)) S = "1" + S;
else S = "0" + S;
}
return S;
}
Compilation message (stderr)
dna.cpp: In function 'int bsearch1(int)':
dna.cpp:24:9: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
return best;
^~~~
dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:71:22: warning: 'best' may be used uninitialized in this function [-Wmaybe-uninitialized]
for(int i = 0; i <= best; i++) S += ans[i];
~~^~~~~~~
grader.cpp: In function 'bool make_test(std::__cxx11::string)':
grader.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < p.size(); i++) {
~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 1; i <= ss.size(); i++) {
~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (pr[i] == p.size()) {
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |