Go to diff to previous submission
#include <stdio.h> #include <string.h> int q, ind; char bug[1200]; char line[2000009]; char tmpLine[10000]; int c; bool jeVslove() { int len = strlen(bug); if(ind < len) return false; for(int i = len-1; i >= 0; i--) { if(bug[i] != line[ind-len+i]) { return false; } } return true; } int main() { while(fgets(tmpLine, 9999, stdin) != NULL) { sscanf(tmpLine, "%d %s", &q, bug); //printf("%d", q); for(int i = 0; i<q; i++) { ind = 0; while(true) { c = getchar(); //printf("%c", c); if(c != EOF) { line[ind] = c; ind++; } if(c == '\n' || c == EOF) { line[ind] = 0; //printf("%s", line); fputs(line, stdout); break; } if(jeVslove()) { ind -= strlen(bug); } } } } return 0; }
--- c4.s1093.cteam122.bugs.cpp.0.bug.cpp +++ c4.s1147.cteam122.bugs.cpp.0.bug.cpp @@ -6,5 +6,5 @@ char line[2000009]; char tmpLine[10000]; -char c; +int c; bool jeVslove() @@ -39,13 +39,18 @@ c = getchar(); //printf("%c", c); - if(c == '\n') + + if(c != EOF) { - line[ind] = 0; - printf("%s\n", line); + line[ind] = c; + ind++; + } + + if(c == '\n' || c == EOF) + { + line[ind] = 0; + //printf("%s", line); + fputs(line, stdout); break; } - - line[ind] = c; - ind++; if(jeVslove())