Submission #69873

# Submission time Handle Problem Language Result Execution time Memory
69873 2018-08-21T18:15:00 Z aquablitz11 Martian DNA (IOI16_dna) C++14
100 / 100
18 ms 764 KB
#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')) {
        str.push_back('1');
        while (true) {
            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;
                }
                str += rep('0', b);
                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:50: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()) {
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 2 ms 576 KB Output is correct
5 Correct 2 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 576 KB Output is correct
9 Correct 3 ms 576 KB Output is correct
10 Correct 3 ms 576 KB Output is correct
11 Correct 2 ms 576 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 2 ms 600 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 3 ms 600 KB Output is correct
16 Correct 2 ms 600 KB Output is correct
17 Correct 3 ms 600 KB Output is correct
18 Correct 3 ms 600 KB Output is correct
19 Correct 3 ms 600 KB Output is correct
20 Correct 2 ms 600 KB Output is correct
21 Correct 2 ms 600 KB Output is correct
22 Correct 3 ms 600 KB Output is correct
23 Correct 3 ms 600 KB Output is correct
24 Correct 2 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 3 ms 600 KB Output is correct
3 Correct 2 ms 600 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 2 ms 600 KB Output is correct
7 Correct 2 ms 600 KB Output is correct
8 Correct 2 ms 600 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 3 ms 600 KB Output is correct
11 Correct 2 ms 600 KB Output is correct
12 Correct 3 ms 600 KB Output is correct
13 Correct 3 ms 600 KB Output is correct
14 Correct 3 ms 600 KB Output is correct
15 Correct 2 ms 620 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 4 ms 620 KB Output is correct
22 Correct 2 ms 620 KB Output is correct
23 Correct 3 ms 620 KB Output is correct
24 Correct 2 ms 620 KB Output is correct
25 Correct 3 ms 620 KB Output is correct
26 Correct 2 ms 620 KB Output is correct
27 Correct 3 ms 620 KB Output is correct
28 Correct 2 ms 620 KB Output is correct
29 Correct 3 ms 620 KB Output is correct
30 Correct 2 ms 620 KB Output is correct
31 Correct 2 ms 620 KB Output is correct
32 Correct 2 ms 620 KB Output is correct
33 Correct 2 ms 620 KB Output is correct
34 Correct 3 ms 620 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 620 KB Output is correct
2 Correct 2 ms 620 KB Output is correct
3 Correct 2 ms 620 KB Output is correct
4 Correct 2 ms 620 KB Output is correct
5 Correct 2 ms 620 KB Output is correct
6 Correct 2 ms 620 KB Output is correct
7 Correct 2 ms 620 KB Output is correct
8 Correct 3 ms 620 KB Output is correct
9 Correct 2 ms 620 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 3 ms 620 KB Output is correct
12 Correct 2 ms 620 KB Output is correct
13 Correct 3 ms 620 KB Output is correct
14 Correct 3 ms 620 KB Output is correct
15 Correct 2 ms 620 KB Output is correct
16 Correct 3 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 2 ms 620 KB Output is correct
20 Correct 3 ms 620 KB Output is correct
21 Correct 3 ms 620 KB Output is correct
22 Correct 13 ms 636 KB Output is correct
23 Correct 13 ms 636 KB Output is correct
24 Correct 13 ms 636 KB Output is correct
25 Correct 18 ms 636 KB Output is correct
26 Correct 16 ms 764 KB Output is correct
27 Correct 11 ms 764 KB Output is correct
28 Correct 12 ms 764 KB Output is correct
29 Correct 3 ms 764 KB Output is correct
30 Correct 2 ms 764 KB Output is correct
31 Correct 10 ms 764 KB Output is correct
32 Correct 3 ms 764 KB Output is correct
33 Correct 14 ms 764 KB Output is correct
34 Correct 13 ms 764 KB Output is correct
35 Correct 12 ms 764 KB Output is correct
36 Correct 12 ms 764 KB Output is correct
37 Correct 10 ms 764 KB Output is correct
38 Correct 8 ms 764 KB Output is correct
39 Correct 8 ms 764 KB Output is correct