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 <bits/stdc++.h>
#include "dna.h"
using namespace std;
string analyse(int n, int t) {
string z = "", o = "";
for (int i = 0; i < n; i++) {
z += '0'; o += '1';
}
if (!make_test("0")) return o;
if (!make_test("1")) return z;
string p;
int lo = 0, mid, res = 0, hi = n;
while (lo <= hi) {
mid = (lo+hi) / 2;
p = z.substr(0, mid);
if (make_test(p)) {
res = mid;
lo = mid+1;
} else {
hi = mid-1;
}
}
p = z.substr(0, res);
int l = res, r = res;
while ((int)p.size() < n) {
if (r < res && make_test(p + '0')) {
p += '0'; r++;
} else {
p += '1'; r = 0;
}
if (l < res && make_test('0' + p)) {
p = '0' + p; l++;
} else {
p = '1' + p; l = 0;
}
if (!make_test(p)) {
int m = (int)p.size();
if (make_test(p.substr(1, m-1))) {
p = p.substr(1, m-1);
while (true) {
if ((int)p.size() == n) return p;
if (r < res && make_test(p + '0')) {
p += '0'; r++;
} else {
p += '1'; r = 0;
}
}
} else {
p = p.substr(0, m-1);
while (true) {
if ((int)p.size() == n) return p;
if (l < res && make_test('0' + p)) {
p = '0' + p; l++;
} else {
p = '1' + p; l = 0;
}
}
}
}
} return p;
}
Compilation message (stderr)
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... |