답안 #69594

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
69594 2018-08-21T09:29:46 Z win11905 Martian DNA (IOI16_dna) C++11
100 / 100
17 ms 1376 KB
#include "dna.h"
#include <bits/stdc++.h>
using namespace std;

string analyse(int n, int t) {
    string str;
    srand(time(NULL));
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        str.push_back(rand() % 2 ? '1' : '0');
        if(make_test(str)) { cnt = 0; continue; }
        str.back() = str.back() == '1' ? '0' : '1'; 
        if(++cnt == 19 || i == n-1) {
            int l = 0, r = cnt;
            while(l < r) {
                int m = l + r>> 1;
                string ret;
                for(int j = 0; j <= i-m; ++j) ret.push_back(str[j]);
                if(make_test(ret)) r = m;
                else l = m+1;
            }
            string ret;
            for(int j = 0; j <= i-r; ++j) ret.push_back(str[j]);
            str = ret;
            break;
        }
    }
    while(str.size() != n) {
        str = (rand() % 2 ? "1" : "0") + str;
        if(make_test(str)) continue;
        str[0] = str[0] == '1' ? '0' : '1';
    }
    return str;
}

Compilation message

dna.cpp: In function 'std::__cxx11::string analyse(int, int)':
dna.cpp:16:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
                 int m = l + r>> 1;
                         ~~^~~
dna.cpp:28:22: 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 3 ms 248 KB Output is correct
2 Correct 3 ms 488 KB Output is correct
3 Correct 2 ms 488 KB Output is correct
4 Correct 2 ms 488 KB Output is correct
5 Correct 4 ms 612 KB Output is correct
6 Correct 2 ms 612 KB Output is correct
7 Correct 3 ms 612 KB Output is correct
8 Correct 2 ms 640 KB Output is correct
9 Correct 2 ms 768 KB Output is correct
10 Correct 2 ms 768 KB Output is correct
11 Correct 2 ms 768 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 2 ms 768 KB Output is correct
14 Correct 2 ms 768 KB Output is correct
15 Correct 3 ms 768 KB Output is correct
16 Correct 2 ms 768 KB Output is correct
17 Correct 2 ms 768 KB Output is correct
18 Correct 3 ms 768 KB Output is correct
19 Correct 3 ms 768 KB Output is correct
20 Correct 2 ms 768 KB Output is correct
21 Correct 3 ms 768 KB Output is correct
22 Correct 2 ms 800 KB Output is correct
23 Correct 3 ms 800 KB Output is correct
24 Correct 3 ms 800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 816 KB Output is correct
2 Correct 2 ms 816 KB Output is correct
3 Correct 2 ms 816 KB Output is correct
4 Correct 2 ms 816 KB Output is correct
5 Correct 3 ms 816 KB Output is correct
6 Correct 2 ms 816 KB Output is correct
7 Correct 2 ms 816 KB Output is correct
8 Correct 2 ms 816 KB Output is correct
9 Correct 3 ms 936 KB Output is correct
10 Correct 2 ms 936 KB Output is correct
11 Correct 2 ms 936 KB Output is correct
12 Correct 2 ms 936 KB Output is correct
13 Correct 3 ms 936 KB Output is correct
14 Correct 3 ms 956 KB Output is correct
15 Correct 2 ms 956 KB Output is correct
16 Correct 3 ms 956 KB Output is correct
17 Correct 3 ms 956 KB Output is correct
18 Correct 2 ms 956 KB Output is correct
19 Correct 3 ms 956 KB Output is correct
20 Correct 2 ms 980 KB Output is correct
21 Correct 3 ms 980 KB Output is correct
22 Correct 2 ms 980 KB Output is correct
23 Correct 3 ms 980 KB Output is correct
24 Correct 2 ms 980 KB Output is correct
25 Correct 3 ms 1020 KB Output is correct
26 Correct 3 ms 1020 KB Output is correct
27 Correct 2 ms 1020 KB Output is correct
28 Correct 3 ms 1020 KB Output is correct
29 Correct 2 ms 1020 KB Output is correct
30 Correct 2 ms 1020 KB Output is correct
31 Correct 3 ms 1020 KB Output is correct
32 Correct 3 ms 1020 KB Output is correct
33 Correct 2 ms 1020 KB Output is correct
34 Correct 3 ms 1020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1060 KB Output is correct
2 Correct 2 ms 1060 KB Output is correct
3 Correct 2 ms 1060 KB Output is correct
4 Correct 2 ms 1060 KB Output is correct
5 Correct 3 ms 1104 KB Output is correct
6 Correct 2 ms 1104 KB Output is correct
7 Correct 2 ms 1104 KB Output is correct
8 Correct 3 ms 1104 KB Output is correct
9 Correct 2 ms 1104 KB Output is correct
10 Correct 2 ms 1104 KB Output is correct
11 Correct 2 ms 1104 KB Output is correct
12 Correct 3 ms 1104 KB Output is correct
13 Correct 2 ms 1104 KB Output is correct
14 Correct 2 ms 1104 KB Output is correct
15 Correct 3 ms 1104 KB Output is correct
16 Correct 3 ms 1104 KB Output is correct
17 Correct 2 ms 1104 KB Output is correct
18 Correct 2 ms 1104 KB Output is correct
19 Correct 3 ms 1104 KB Output is correct
20 Correct 3 ms 1104 KB Output is correct
21 Correct 3 ms 1104 KB Output is correct
22 Correct 17 ms 1176 KB Output is correct
23 Correct 13 ms 1180 KB Output is correct
24 Correct 15 ms 1184 KB Output is correct
25 Correct 13 ms 1188 KB Output is correct
26 Correct 17 ms 1320 KB Output is correct
27 Correct 9 ms 1320 KB Output is correct
28 Correct 9 ms 1320 KB Output is correct
29 Correct 11 ms 1320 KB Output is correct
30 Correct 10 ms 1320 KB Output is correct
31 Correct 10 ms 1320 KB Output is correct
32 Correct 10 ms 1368 KB Output is correct
33 Correct 11 ms 1368 KB Output is correct
34 Correct 12 ms 1368 KB Output is correct
35 Correct 11 ms 1368 KB Output is correct
36 Correct 11 ms 1368 KB Output is correct
37 Correct 11 ms 1368 KB Output is correct
38 Correct 12 ms 1368 KB Output is correct
39 Correct 11 ms 1376 KB Output is correct