Go to diff to previous submission
#include <stdio.h> #include <string.h> int q, ind, len; char bug[1200]; char line[2000009]; char tmpLine[10000]; int c; bool jeVslove() { 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); len = strlen(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 -= len; } } } fgets(tmpLine, 1000, stdin); } return 0; }