fork download
  1. program antivirus;
  2.  
  3. var
  4. M, N1, N2, N3, N4, T, p1, p2, p3, p4, test, i : LongInt;
  5. F1, F2, F3, F4 : AnsiString;
  6. corrispondenza : boolean;
  7.  
  8. begin
  9. {
  10.   decommenta le due righe seguenti se vuoi leggere/scrivere da file
  11.   assign(input, 'input.txt'); reset(input);
  12.   assign(output, 'output.txt'); rewrite(output);
  13. }
  14.  
  15. ReadLn(T);
  16. for test:=1 to T do begin
  17. ReadLn();
  18. ReadLn(N1, N2, N3, N4);
  19.  
  20. ReadLn(M);
  21.  
  22. ReadLn(F1);
  23.  
  24. ReadLn(F2);
  25.  
  26. ReadLn(F3);
  27.  
  28. ReadLn(F4);
  29.  
  30. for p1:= 1 to N1-M+1 do
  31. for p2:= 1 to N2-M +1 do
  32. for p3:=1 to N3-M +1 do
  33. for p4:= 1 to N4-M+1 do
  34. begin
  35. corrispondenza:=true;
  36. for i:= 0 to M -1 do
  37. if (F1[p1 + i] <> F2[p2 + i]) or ( F2[p2 + i] <> F3[p3 + i]) or (F3[p3 + i] <> F4[p4 + i]) then corrispondenza:= false;
  38. if corrispondenza=true then
  39. begin
  40. Write('Case #', test, ': ');
  41. WriteLn(p1-1, ' ', p2-1, ' ', p3-1, ' ', p4-1);
  42. end;
  43. end;
  44. end;
  45. end.
  46.  
Success #stdin #stdout 0.01s 5288KB
stdin
2

8 12 10 7
4
ananasso
associazione
tassonomia
massone

6 9 11 10
3
simone
ponessimo
milionesimo
cassonetto
stdout
Case #1: 4 0 1 1
Case #2: 3 1 4 4