#include <bits/stdc++.h>
#include "dna.h"
using namespace std;
inline string rep(char c, int n) {
assert(c == '0' || c == '1');
string ret;
for (int i = 0; i < n; ++i)
ret.push_back(c);
return ret;
}
string analyse(int n, int t)
{
int b = 0, e = n;
while (b < e) {
int m = (b+e+1)/2;
if (make_test(rep('0', m))) b = m;
else e = m-1;
}
int max0len = e;
if (max0len == n) return rep('0', n);
if (max0len == 0) return rep('1', n);
string str = rep('0', max0len);
if (make_test(str+'1')) {
while (true) {
str.push_back('1');
bool ok = false;
for (int i = 0; i <= max0len && str.size()+i+1 <= n; ++i) {
string q = str + rep('0', i) + '1';
if (make_test(q)) {
str = q;
ok = true;
break;
}
}
if (!ok) {
int b = 0, e = max0len;
while (b < e) {
int m = (b+e+1)/2;
string q = str + rep('0', m);
if (make_test(q)) b = m;
else e = m-1;
}
break;
}
}
}
while (str.size() < n) {
str = "0" + str;
if (!make_test(str))
str[0] = str[0]=='0' ? '1' : '0';
}
return str;
}
Compilation message
dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:29:60: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i <= max0len && str.size()+i+1 <= n; ++i) {
~~~~~~~~~~~~~~~^~~~
dna.cpp:49:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (str.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 |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
488 KB |
Output is correct |
3 |
Correct |
3 ms |
576 KB |
Output is correct |
4 |
Correct |
2 ms |
576 KB |
Output is correct |
5 |
Correct |
3 ms |
576 KB |
Output is correct |
6 |
Correct |
2 ms |
576 KB |
Output is correct |
7 |
Correct |
2 ms |
576 KB |
Output is correct |
8 |
Correct |
2 ms |
592 KB |
Output is correct |
9 |
Incorrect |
2 ms |
596 KB |
Wrong DNA |
10 |
Incorrect |
2 ms |
596 KB |
Wrong DNA |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Incorrect |
2 ms |
596 KB |
Wrong DNA |
13 |
Incorrect |
2 ms |
636 KB |
Wrong DNA |
14 |
Correct |
2 ms |
636 KB |
Output is correct |
15 |
Correct |
2 ms |
644 KB |
Output is correct |
16 |
Incorrect |
2 ms |
644 KB |
Wrong DNA |
17 |
Correct |
2 ms |
668 KB |
Output is correct |
18 |
Incorrect |
2 ms |
668 KB |
Wrong DNA |
19 |
Correct |
2 ms |
668 KB |
Output is correct |
20 |
Correct |
2 ms |
668 KB |
Output is correct |
21 |
Correct |
2 ms |
668 KB |
Output is correct |
22 |
Incorrect |
2 ms |
728 KB |
Wrong DNA |
23 |
Incorrect |
2 ms |
728 KB |
Wrong DNA |
24 |
Correct |
2 ms |
728 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
728 KB |
Output is correct |
2 |
Correct |
2 ms |
728 KB |
Output is correct |
3 |
Correct |
2 ms |
728 KB |
Output is correct |
4 |
Correct |
2 ms |
728 KB |
Output is correct |
5 |
Correct |
2 ms |
728 KB |
Output is correct |
6 |
Correct |
3 ms |
756 KB |
Output is correct |
7 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
8 |
Correct |
2 ms |
756 KB |
Output is correct |
9 |
Correct |
2 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
756 KB |
Output is correct |
12 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
13 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
14 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
15 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
16 |
Correct |
2 ms |
756 KB |
Output is correct |
17 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
18 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
19 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
20 |
Incorrect |
2 ms |
756 KB |
Wrong DNA |
21 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
22 |
Incorrect |
3 ms |
816 KB |
Wrong DNA |
23 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
24 |
Correct |
3 ms |
816 KB |
Output is correct |
25 |
Correct |
3 ms |
816 KB |
Output is correct |
26 |
Correct |
2 ms |
816 KB |
Output is correct |
27 |
Correct |
2 ms |
816 KB |
Output is correct |
28 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
29 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
30 |
Incorrect |
3 ms |
816 KB |
Wrong DNA |
31 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
32 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
33 |
Incorrect |
2 ms |
816 KB |
Wrong DNA |
34 |
Correct |
2 ms |
816 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
816 KB |
Output is correct |
2 |
Correct |
2 ms |
992 KB |
Output is correct |
3 |
Correct |
2 ms |
992 KB |
Output is correct |
4 |
Correct |
2 ms |
992 KB |
Output is correct |
5 |
Correct |
2 ms |
992 KB |
Output is correct |
6 |
Correct |
2 ms |
992 KB |
Output is correct |
7 |
Incorrect |
2 ms |
992 KB |
Wrong DNA |
8 |
Correct |
2 ms |
992 KB |
Output is correct |
9 |
Correct |
2 ms |
992 KB |
Output is correct |
10 |
Correct |
2 ms |
992 KB |
Output is correct |
11 |
Correct |
2 ms |
992 KB |
Output is correct |
12 |
Incorrect |
2 ms |
992 KB |
Wrong DNA |
13 |
Correct |
3 ms |
992 KB |
Output is correct |
14 |
Incorrect |
3 ms |
992 KB |
Wrong DNA |
15 |
Incorrect |
3 ms |
992 KB |
Wrong DNA |
16 |
Correct |
2 ms |
992 KB |
Output is correct |
17 |
Incorrect |
3 ms |
992 KB |
Wrong DNA |
18 |
Incorrect |
2 ms |
992 KB |
Wrong DNA |
19 |
Incorrect |
2 ms |
992 KB |
Wrong DNA |
20 |
Incorrect |
3 ms |
992 KB |
Wrong DNA |
21 |
Incorrect |
3 ms |
992 KB |
Wrong DNA |
22 |
Incorrect |
15 ms |
992 KB |
Wrong DNA |
23 |
Incorrect |
11 ms |
992 KB |
Wrong DNA |
24 |
Incorrect |
11 ms |
992 KB |
Wrong DNA |
25 |
Incorrect |
15 ms |
992 KB |
Wrong DNA |
26 |
Incorrect |
14 ms |
1092 KB |
Wrong DNA |
27 |
Incorrect |
16 ms |
1092 KB |
Wrong DNA |
28 |
Incorrect |
11 ms |
1092 KB |
Wrong DNA |
29 |
Correct |
4 ms |
1112 KB |
Output is correct |
30 |
Correct |
3 ms |
1112 KB |
Output is correct |
31 |
Correct |
6 ms |
1112 KB |
Output is correct |
32 |
Correct |
3 ms |
1112 KB |
Output is correct |
33 |
Incorrect |
13 ms |
1112 KB |
Wrong DNA |
34 |
Incorrect |
12 ms |
1112 KB |
Wrong DNA |
35 |
Incorrect |
12 ms |
1112 KB |
Wrong DNA |
36 |
Incorrect |
13 ms |
1112 KB |
Wrong DNA |
37 |
Incorrect |
12 ms |
1112 KB |
Wrong DNA |
38 |
Incorrect |
5 ms |
1112 KB |
Wrong DNA |
39 |
Correct |
9 ms |
1112 KB |
Output is correct |