#include <bits/stdc++.h>
#include "dna.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define fillchar(a, s) memset((a), (s), sizeof(a))
string analyse (int n, int t) {
//find zeroes max
int lo = 0, hi = n + 1;
while (hi - lo > 1) {
int mid = (lo + hi) / 2;
if (make_test(string(mid, '0'))) {
lo = mid;
} else {
hi = mid;
}
}
if (lo == n) {
return string(n, '0');
}
if (lo == 0) {
return string(n, '1');
}
int mxzero = lo;
string ans(mxzero, '0');
for (int i = 0; i < n - mxzero; i++) {
if (make_test(ans + '1')) {
ans += '1';
} else {
int end0 = 0;
for (int j = ans.size() - 1; j >= 0; j--) {
if (ans[j] != '0') {
break;
}
end0++;
}
if (end0 > mxzero) {
break;
}
ans += '0';
}
}
lo = mxzero;
hi = ans.size() + 1;
while (hi - lo > 1) {
int mid = (lo + hi) / 2;
if (make_test(ans.substr(0, mid))) {
lo = mid;
} else {
hi = mid;
}
}
ans = ans.substr(0, lo);
while (ans.size() < n) {
if (make_test('1' + ans)) {
ans = '1' + ans;
} else {
ans = '0' + ans;
}
}
return ans;
}
Compilation message
dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:67:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (ans.size() < n) {
~~~~~~~~~~~^~~
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()) {
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
564 KB |
Output is correct |
4 |
Correct |
2 ms |
564 KB |
Output is correct |
5 |
Correct |
3 ms |
564 KB |
Output is correct |
6 |
Correct |
2 ms |
564 KB |
Output is correct |
7 |
Correct |
3 ms |
564 KB |
Output is correct |
8 |
Correct |
2 ms |
564 KB |
Output is correct |
9 |
Correct |
2 ms |
564 KB |
Output is correct |
10 |
Correct |
2 ms |
564 KB |
Output is correct |
11 |
Correct |
2 ms |
564 KB |
Output is correct |
12 |
Correct |
9 ms |
564 KB |
Output is correct |
13 |
Correct |
3 ms |
564 KB |
Output is correct |
14 |
Correct |
2 ms |
564 KB |
Output is correct |
15 |
Correct |
2 ms |
588 KB |
Output is correct |
16 |
Correct |
2 ms |
620 KB |
Output is correct |
17 |
Correct |
2 ms |
620 KB |
Output is correct |
18 |
Correct |
3 ms |
620 KB |
Output is correct |
19 |
Correct |
3 ms |
620 KB |
Output is correct |
20 |
Correct |
3 ms |
620 KB |
Output is correct |
21 |
Correct |
3 ms |
636 KB |
Output is correct |
22 |
Correct |
3 ms |
636 KB |
Output is correct |
23 |
Correct |
3 ms |
636 KB |
Output is correct |
24 |
Correct |
4 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
636 KB |
Output is correct |
2 |
Correct |
3 ms |
636 KB |
Output is correct |
3 |
Correct |
3 ms |
636 KB |
Output is correct |
4 |
Correct |
3 ms |
636 KB |
Output is correct |
5 |
Correct |
3 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
3 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
636 KB |
Output is correct |
10 |
Correct |
3 ms |
636 KB |
Output is correct |
11 |
Correct |
3 ms |
636 KB |
Output is correct |
12 |
Correct |
2 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
636 KB |
Output is correct |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
3 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
2 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
3 ms |
636 KB |
Output is correct |
20 |
Correct |
3 ms |
636 KB |
Output is correct |
21 |
Correct |
4 ms |
636 KB |
Output is correct |
22 |
Correct |
4 ms |
636 KB |
Output is correct |
23 |
Correct |
4 ms |
636 KB |
Output is correct |
24 |
Correct |
3 ms |
636 KB |
Output is correct |
25 |
Correct |
3 ms |
636 KB |
Output is correct |
26 |
Correct |
2 ms |
636 KB |
Output is correct |
27 |
Correct |
3 ms |
636 KB |
Output is correct |
28 |
Correct |
3 ms |
636 KB |
Output is correct |
29 |
Correct |
3 ms |
636 KB |
Output is correct |
30 |
Correct |
3 ms |
636 KB |
Output is correct |
31 |
Correct |
2 ms |
636 KB |
Output is correct |
32 |
Correct |
3 ms |
636 KB |
Output is correct |
33 |
Correct |
3 ms |
636 KB |
Output is correct |
34 |
Correct |
3 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
636 KB |
Output is correct |
2 |
Correct |
3 ms |
636 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
4 |
Correct |
2 ms |
636 KB |
Output is correct |
5 |
Correct |
3 ms |
636 KB |
Output is correct |
6 |
Correct |
2 ms |
636 KB |
Output is correct |
7 |
Correct |
2 ms |
636 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
3 ms |
636 KB |
Output is correct |
10 |
Correct |
2 ms |
636 KB |
Output is correct |
11 |
Correct |
3 ms |
636 KB |
Output is correct |
12 |
Correct |
3 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
636 KB |
Output is correct |
14 |
Correct |
3 ms |
636 KB |
Output is correct |
15 |
Correct |
3 ms |
636 KB |
Output is correct |
16 |
Correct |
3 ms |
636 KB |
Output is correct |
17 |
Correct |
3 ms |
636 KB |
Output is correct |
18 |
Correct |
3 ms |
636 KB |
Output is correct |
19 |
Correct |
3 ms |
636 KB |
Output is correct |
20 |
Correct |
3 ms |
636 KB |
Output is correct |
21 |
Correct |
2 ms |
636 KB |
Output is correct |
22 |
Correct |
18 ms |
636 KB |
Output is correct |
23 |
Correct |
18 ms |
636 KB |
Output is correct |
24 |
Correct |
16 ms |
636 KB |
Output is correct |
25 |
Correct |
19 ms |
636 KB |
Output is correct |
26 |
Correct |
22 ms |
636 KB |
Output is correct |
27 |
Correct |
12 ms |
636 KB |
Output is correct |
28 |
Correct |
11 ms |
636 KB |
Output is correct |
29 |
Correct |
3 ms |
640 KB |
Output is correct |
30 |
Correct |
2 ms |
640 KB |
Output is correct |
31 |
Correct |
9 ms |
640 KB |
Output is correct |
32 |
Correct |
2 ms |
640 KB |
Output is correct |
33 |
Correct |
12 ms |
640 KB |
Output is correct |
34 |
Correct |
13 ms |
640 KB |
Output is correct |
35 |
Correct |
12 ms |
640 KB |
Output is correct |
36 |
Correct |
12 ms |
640 KB |
Output is correct |
37 |
Correct |
11 ms |
760 KB |
Output is correct |
38 |
Correct |
7 ms |
760 KB |
Output is correct |
39 |
Correct |
7 ms |
760 KB |
Output is correct |