# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
116088 |
2019-06-10T12:57:36 Z |
tjd229 |
Martian DNA (IOI16_dna) |
C++14 |
|
15 ms |
404 KB |
#include "dna.h"
#include <cstdlib>
#define reg register
std::string make_str(int len, char c) {
std::string s = "";
for (reg int i = 0; i < len; ++i) s += c;
return s;
}
std::string analyse(int n, int t) {
int cnt = 0;
int l = 1, r = n;
while (l <= r) {
int m = (l + r) >> 1;
if(make_test(make_str(m,'0'))) cnt=m,l=m+1;
else r=m-1;
}
if (!cnt) return make_str(n,'1');
std::string s = make_str(cnt, '0');
int stk = cnt;
while (s.size()<n && stk<=cnt) {//len<n && stk
if (make_test(s + '1')) s += '1',stk=0;
else s += '0',++stk;
}
if (s.size() == n && make_test(s)) return s;
int bnd = s.size() - stk;
std::string sub = "";
for (reg int i = 0; i < bnd; ++i) sub += s[i];
l = 0, r = stk - 1; cnt = 0;
while (l <= r) {
int m = (l + r) >> 1;
if (make_test(sub + make_str(m, '0'))) cnt=m,l = m + 1;
else r = m - 1;
}
s = sub + make_str(cnt,'0');
while (s.size() < n) {
s = '1' + s;
if (!make_test(s)) s[0] = '0';
}
return s;
}
Compilation message
dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:21:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (s.size()<n && stk<=cnt) {//len<n && stk
~~~~~~~~^~
dna.cpp:25:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (s.size() == n && make_test(s)) return s;
~~~~~~~~~^~~~
dna.cpp:36:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while (s.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()) {
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
2 ms |
256 KB |
Output is correct |
23 |
Correct |
2 ms |
256 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
284 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
2 ms |
384 KB |
Output is correct |
20 |
Correct |
2 ms |
404 KB |
Output is correct |
21 |
Correct |
2 ms |
356 KB |
Output is correct |
22 |
Correct |
2 ms |
384 KB |
Output is correct |
23 |
Correct |
2 ms |
384 KB |
Output is correct |
24 |
Correct |
2 ms |
384 KB |
Output is correct |
25 |
Correct |
2 ms |
256 KB |
Output is correct |
26 |
Correct |
2 ms |
256 KB |
Output is correct |
27 |
Correct |
2 ms |
256 KB |
Output is correct |
28 |
Correct |
2 ms |
256 KB |
Output is correct |
29 |
Correct |
2 ms |
256 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
3 ms |
356 KB |
Output is correct |
32 |
Correct |
3 ms |
256 KB |
Output is correct |
33 |
Correct |
2 ms |
256 KB |
Output is correct |
34 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
384 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
2 ms |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
2 ms |
256 KB |
Output is correct |
22 |
Correct |
10 ms |
384 KB |
Output is correct |
23 |
Correct |
11 ms |
384 KB |
Output is correct |
24 |
Correct |
11 ms |
384 KB |
Output is correct |
25 |
Correct |
15 ms |
384 KB |
Output is correct |
26 |
Correct |
14 ms |
384 KB |
Output is correct |
27 |
Correct |
8 ms |
384 KB |
Output is correct |
28 |
Correct |
8 ms |
384 KB |
Output is correct |
29 |
Correct |
2 ms |
384 KB |
Output is correct |
30 |
Correct |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
7 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
10 ms |
384 KB |
Output is correct |
34 |
Correct |
10 ms |
384 KB |
Output is correct |
35 |
Correct |
9 ms |
384 KB |
Output is correct |
36 |
Correct |
9 ms |
384 KB |
Output is correct |
37 |
Correct |
8 ms |
384 KB |
Output is correct |
38 |
Correct |
6 ms |
384 KB |
Output is correct |
39 |
Correct |
7 ms |
384 KB |
Output is correct |