답안 #20589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
20589 2017-02-12T14:06:44 Z model_code Martian DNA (IOI16_dna) C
100 / 100
9 ms 1144 KB
#include "dna_c.h"

#include "strings.h"

void zeroes(int m, char* s) {
    for (int i = 0; i < m; ++i)
        s[i] = '0';
    s[m] = 0;
}

char s[2001];
char test[2001];
char temp[2001];

char* analyse(int n, int t) {

    int l = 0, r = n + 1;
    while (l < r - 1) {
        int m = (l + r) >> 1;
        zeroes(m, test);
        if (make_test(test))
            l = m;
        else
            r = m;
    }

    zeroes(l, s);
    int zeroesCount = 0;
    int maxZeroesCount = l;
    int slen = l;
    while (1) {
        strcat(s, "1");
        slen++;
        if (!make_test(s)) {
            s[slen - 1] = '0';
            ++zeroesCount;
        } else {
            zeroesCount = 0;
        }
        if (zeroesCount + maxZeroesCount >= n || zeroesCount >= maxZeroesCount + 1)
            break;
    }
    
    l = 0, r = zeroesCount;
    s[slen - zeroesCount] = 0;
    slen -= zeroesCount;

    while (l < r - 1) {
        int m = (l + r) >> 1;
        strcpy(test, s);
        zeroes(m, temp);
        strcat(test, temp);
        if (make_test(test))
            l = m;
        else
            r = m;
    }

    zeroes(l, temp);
    strcat(s, temp);
    slen += l;

    while (slen < n) {
        strcpy(temp, "1");
        strcat(temp, s);
        strcpy(s, temp);
        slen++;
        if (!make_test(s)) {
            s[0] = '0';
        }
    }

    return s;
}                       

Compilation message

dna.c: In function 'analyse':
dna.c:32:9: warning: implicit declaration of function 'strcat' [-Wimplicit-function-declaration]
         strcat(s, "1");
         ^
dna.c:32:9: warning: incompatible implicit declaration of built-in function 'strcat'
dna.c:32:9: note: include '<string.h>' or provide a declaration of 'strcat'
dna.c:50:9: warning: implicit declaration of function 'strcpy' [-Wimplicit-function-declaration]
         strcpy(test, s);
         ^
dna.c:50:9: warning: incompatible implicit declaration of built-in function 'strcpy'
dna.c:50:9: note: include '<string.h>' or provide a declaration of 'strcpy'
dna.c:52:9: warning: incompatible implicit declaration of built-in function 'strcat'
         strcat(test, temp);
         ^
dna.c:52:9: note: include '<string.h>' or provide a declaration of 'strcat'
dna.c:60:5: warning: incompatible implicit declaration of built-in function 'strcat'
     strcat(s, temp);
     ^
dna.c:60:5: note: include '<string.h>' or provide a declaration of 'strcat'
dna.c:64:9: warning: incompatible implicit declaration of built-in function 'strcpy'
         strcpy(temp, "1");
         ^
dna.c:64:9: note: include '<string.h>' or provide a declaration of 'strcpy'
grader.c: In function 'main':
grader.c:46:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%s", s);
     ^
grader.c:47:5: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &t);
     ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1144 KB Output is correct
2 Correct 0 ms 1144 KB Output is correct
3 Correct 0 ms 1144 KB Output is correct
4 Correct 0 ms 1144 KB Output is correct
5 Correct 0 ms 1144 KB Output is correct
6 Correct 0 ms 1144 KB Output is correct
7 Correct 0 ms 1144 KB Output is correct
8 Correct 0 ms 1144 KB Output is correct
9 Correct 0 ms 1144 KB Output is correct
10 Correct 0 ms 1144 KB Output is correct
11 Correct 0 ms 1144 KB Output is correct
12 Correct 0 ms 1144 KB Output is correct
13 Correct 0 ms 1144 KB Output is correct
14 Correct 0 ms 1144 KB Output is correct
15 Correct 0 ms 1144 KB Output is correct
16 Correct 0 ms 1144 KB Output is correct
17 Correct 0 ms 1144 KB Output is correct
18 Correct 0 ms 1144 KB Output is correct
19 Correct 0 ms 1144 KB Output is correct
20 Correct 0 ms 1144 KB Output is correct
21 Correct 0 ms 1144 KB Output is correct
22 Correct 0 ms 1144 KB Output is correct
23 Correct 0 ms 1144 KB Output is correct
24 Correct 0 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1144 KB Output is correct
2 Correct 0 ms 1144 KB Output is correct
3 Correct 0 ms 1144 KB Output is correct
4 Correct 0 ms 1144 KB Output is correct
5 Correct 0 ms 1144 KB Output is correct
6 Correct 0 ms 1144 KB Output is correct
7 Correct 0 ms 1144 KB Output is correct
8 Correct 0 ms 1144 KB Output is correct
9 Correct 0 ms 1144 KB Output is correct
10 Correct 0 ms 1144 KB Output is correct
11 Correct 0 ms 1144 KB Output is correct
12 Correct 0 ms 1144 KB Output is correct
13 Correct 0 ms 1144 KB Output is correct
14 Correct 0 ms 1144 KB Output is correct
15 Correct 0 ms 1144 KB Output is correct
16 Correct 0 ms 1144 KB Output is correct
17 Correct 0 ms 1144 KB Output is correct
18 Correct 0 ms 1144 KB Output is correct
19 Correct 0 ms 1144 KB Output is correct
20 Correct 0 ms 1144 KB Output is correct
21 Correct 0 ms 1144 KB Output is correct
22 Correct 0 ms 1144 KB Output is correct
23 Correct 0 ms 1144 KB Output is correct
24 Correct 0 ms 1144 KB Output is correct
25 Correct 0 ms 1144 KB Output is correct
26 Correct 0 ms 1144 KB Output is correct
27 Correct 0 ms 1144 KB Output is correct
28 Correct 0 ms 1144 KB Output is correct
29 Correct 0 ms 1144 KB Output is correct
30 Correct 0 ms 1144 KB Output is correct
31 Correct 0 ms 1144 KB Output is correct
32 Correct 0 ms 1144 KB Output is correct
33 Correct 0 ms 1144 KB Output is correct
34 Correct 0 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1144 KB Output is correct
2 Correct 0 ms 1144 KB Output is correct
3 Correct 0 ms 1144 KB Output is correct
4 Correct 0 ms 1144 KB Output is correct
5 Correct 0 ms 1144 KB Output is correct
6 Correct 0 ms 1144 KB Output is correct
7 Correct 0 ms 1144 KB Output is correct
8 Correct 0 ms 1144 KB Output is correct
9 Correct 0 ms 1144 KB Output is correct
10 Correct 0 ms 1144 KB Output is correct
11 Correct 0 ms 1144 KB Output is correct
12 Correct 0 ms 1144 KB Output is correct
13 Correct 0 ms 1144 KB Output is correct
14 Correct 0 ms 1144 KB Output is correct
15 Correct 0 ms 1144 KB Output is correct
16 Correct 0 ms 1144 KB Output is correct
17 Correct 0 ms 1144 KB Output is correct
18 Correct 0 ms 1144 KB Output is correct
19 Correct 0 ms 1144 KB Output is correct
20 Correct 0 ms 1144 KB Output is correct
21 Correct 0 ms 1144 KB Output is correct
22 Correct 6 ms 1144 KB Output is correct
23 Correct 6 ms 1144 KB Output is correct
24 Correct 6 ms 1144 KB Output is correct
25 Correct 9 ms 1144 KB Output is correct
26 Correct 9 ms 1144 KB Output is correct
27 Correct 3 ms 1144 KB Output is correct
28 Correct 3 ms 1144 KB Output is correct
29 Correct 0 ms 1144 KB Output is correct
30 Correct 3 ms 1144 KB Output is correct
31 Correct 3 ms 1144 KB Output is correct
32 Correct 0 ms 1144 KB Output is correct
33 Correct 3 ms 1144 KB Output is correct
34 Correct 3 ms 1144 KB Output is correct
35 Correct 3 ms 1144 KB Output is correct
36 Correct 3 ms 1144 KB Output is correct
37 Correct 3 ms 1144 KB Output is correct
38 Correct 3 ms 1144 KB Output is correct
39 Correct 6 ms 1144 KB Output is correct