fork download
  1. program Project2out;
  2.  
  3.  
  4. type
  5. tpoint = record
  6. x,y:longint;
  7. end;
  8.  
  9. var
  10. t,ti,r,s,k,i,j,l:longint;
  11. map,map2:array of array of longint;
  12. str:array of Tpoint;
  13. tmp:char;
  14.  
  15. begin
  16.  
  17. readln(t);
  18. for ti:=1 to t do
  19. begin
  20. readln(r,s);
  21. setlength(map,r,s);setlength(map2,r,s);
  22. for i:=0 to r-1 do
  23. begin
  24. for j:=0 to s-1 do
  25. begin
  26. read(tmp);
  27. map[i,j]:=ord(tmp);
  28. end;
  29. readln;
  30. end;
  31. readln(k);
  32. setlength(str,k);
  33. for i:=0 to k-1 do readln(str[i].x,str[i].y);
  34. for i:=0 to r-1 do
  35. for j:=0 to s-1 do
  36. begin
  37. map2[i,j]:=map[i,j];
  38. for l:=0 to k-1 do
  39. if(i+str[l].x > -1)and
  40. (i+str[l].x < r)and
  41. (j+str[l].y > -1)and
  42. (j+str[l].y < s)then
  43. if map2[i,j] > map[i+str[l].x,j+str[l].y] then map2[i,j]:=map[i+str[l].x,j+str[l].y];
  44. end;
  45. //writeln(length(map[0]));
  46. for i:=0 to r-1 do
  47. begin
  48. for j:=0 to s-1 do write(chr(map2[i,j]));
  49. writeln;
  50. end;
  51. end;
  52.  
  53. end.
Success #stdin #stdout 0.01s 256KB
stdin
2
2 3
abc
def
2
-1 -1
0 0
3 2
da
db
dc
3
0 0
1 1
-1 0
stdout
abc
dab
ba
ca
db