Submission #20589

#TimeUsernameProblemLanguageResultExecution timeMemory
20589model_codeMartian DNA (IOI16_dna)C11
100 / 100
9 ms1144 KiB
#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 (stderr)

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);
     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...