Advertisement
KennasSticky

BigFungus.pas

Sep 9th, 2022 (edited)
1,778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.50 KB | None | 0 0
  1. program fungus;
  2. const
  3.   maxn = 110;
  4.   iMod = 1000000007;
  5.   moves : array[1..4, 1..2] of Integer = ((1,0),(0,1),(-1,0),(0,-1));
  6. var
  7.   iArr : array[0..maxn] of array[0..maxn] of array[0..1] of int64;
  8.   k, n, m, i, j, cur : integer;
  9.   curX, curY : integer;
  10.   iAns, iTotal : int64;
  11.  
  12. begin
  13.  
  14.     // Do not focus on the entire solution, just take note of how the various structures are implemented
  15.  
  16.   Read(k);
  17.   Read(n);
  18.   Read(m);
  19.  
  20.   iArr[1][1][1] := 1;
  21.   iArr[1][1][0] := 1;
  22.  
  23.   while (k > 0) do
  24.     begin
  25.  
  26.       iAns := 0;
  27.  
  28.       for I := 1 to n do
  29.         for j := 1 to m do
  30.             begin
  31.               iTotal := 0;
  32.               for cur := 1 to 4 do
  33.                 begin
  34.                   curX := i + moves[cur][1];
  35.                   curY := j + moves[cur][2];
  36.  
  37.                   if (curX < 1) or (curX > n) then continue;
  38.                   if (curY < 1) or (curY > m) then continue;
  39.  
  40.                   if (moves[cur][1] = 1) or (moves[cur][2] = 1) then
  41.                     begin
  42.                       iTotal := iTotal + (iArr[curX][curY][1] mod iMod);
  43.                     end
  44.                   else
  45.                     begin
  46.                       iTotal := iTotal + (iArr[curX][curY][0] mod iMod);
  47.                     end;
  48.                 end;
  49.  
  50.               iArr[i][j][0] := iArr[i][j][1];
  51.               iArr[i][j][1] := iArr[i][j][1] + (iTotal mod iMod);
  52.               iAns := iAns + iArr[i][j][1];
  53.             end;
  54.  
  55.       Dec(k);
  56.     end;
  57.  
  58.   Writeln(iAns mod iMod);
  59. end.
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement