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;
#define sp << " " <<
#define nl << "\n"
string create(string i, int j){
string res;
while(j--) res += i;
return res;
}
string analyse(int n, int t){
string ans;
if(!make_test("1")){
return create("0", n);
}
int low = 1, high = n;
while(low<high){
int mid = (low+high)/2;
if(make_test(create("1", mid+1))) low = mid+1;
else high = mid;
}
ans = create("1", low);
int prevOnes = high, maxOnes = high;
bool backward = false;
while(!(backward and ans.size()==n)){
if(backward){
if(make_test("0"+ans)) ans = "0"+ans;
else ans = "1"+ans;
}else{
if(make_test(ans+"0")) ans += "0", prevOnes = 0;
else{
ans += "1";
++prevOnes;
if(prevOnes>maxOnes){ // found endpoint
string temp; swap(temp, ans);
for(int i=0; i+maxOnes+1<(int)temp.size(); ++i) ans.push_back(temp[i]);
low = 0, high = maxOnes;
while(low<high){
int mid = (low+high)/2;
if(make_test(ans+create("1", mid+1))) low = mid+1;
else high = mid;
}
ans += create("1", low);
backward = true;
}
}
}
}
return ans;
}
Compilation message (stderr)
dna.cpp: In function 'std::string analyse(int, int)':
dna.cpp:29:33: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
29 | while(!(backward and ans.size()==n)){
| ~~~~~~~~~~^~~
grader.cpp: In function 'bool make_test(std::string)':
grader.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for (int i = 0; i < p.size(); i++) {
| ~~^~~~~~~~~~
grader.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for (int i = 1; i <= ss.size(); i++) {
| ~~^~~~~~~~~~~~
grader.cpp:28:13: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | 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... |