Source code for submission s1289

Go to diff to previous submission

bug.cpp

  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int q, ind, len;
  5. char bug[1200];
  6. char line[2000009];
  7. char tmpLine[10000];
  8. int c;
  9.  
  10. bool jeVslove()
  11. {
  12. if(ind < len)
  13. return false;
  14.  
  15. for(int i = len-1; i >= 0; i--)
  16. {
  17. if(bug[i] != line[ind-len+i])
  18. {
  19. return false;
  20. }
  21. }
  22.  
  23. return true;
  24. }
  25.  
  26. int main()
  27. {
  28. while(fgets(tmpLine, 9999, stdin) != NULL)
  29. {
  30. sscanf(tmpLine, "%d %s", &q, bug);
  31. len = strlen(bug);
  32. //printf("%d", q);
  33. for(int i = 0; i<q; i++)
  34. {
  35. ind = 0;
  36. while(true)
  37. {
  38. c = getchar();
  39. //printf("%c", c);
  40.  
  41. if(c != EOF)
  42. {
  43. line[ind] = c;
  44. ind++;
  45. }
  46.  
  47. if(c == '\n' || c == EOF)
  48. {
  49. line[ind] = 0;
  50. //printf("%s", line);
  51. fputs(line, stdout);
  52. break;
  53. }
  54.  
  55. if(jeVslove())
  56. {
  57. ind -= len;
  58. }
  59.  
  60. }
  61. }
  62.  
  63. fgets(tmpLine, 1000, stdin);
  64. }
  65.  
  66.  
  67. return 0;
  68. }

Diff to submission s1273

bug.cpp

--- c4.s1273.cteam122.bugs.cpp.0.bug.cpp
+++ c4.s1289.cteam122.bugs.cpp.0.bug.cpp
@@ -60,4 +60,6 @@
       }
     }
+    
+    fgets(tmpLine, 1000, stdin);
   }