fork download
  1. var i,j,r:integer;
  2. s,a:array[1..4,1..4] of char;
  3. c:string;
  4. begin
  5. for i:=1 to 4 do begin
  6. readln(s[1,i]);
  7. readln(s[2,i]);
  8. readln(s[3,i]);
  9. readln(s[4,i]); end;
  10. for j:=1 to 4 do begin
  11. read(a[1,j]);
  12. read(a[2,j]);
  13. read(a[3,j]);
  14. read(a[4,j]); end;
  15. writeln;
  16. for i:=1 to 4 do
  17. for j:=1 to 4 do
  18. if s[i,j]='X' then
  19. c:=c+a[i,j];
  20.  
  21. for j:=1 to 4 do
  22. for i:=4 downto 1 do
  23. if s[i,j]='X' then c:=c+a[j,5-i];
  24.  
  25. for i:=4 downto 1 do
  26. for j:=4 downto 1 do
  27. if s[i,j]='X' then c:=c+a[5-i,5-j];
  28.  
  29. for j:=4 downto 1 do
  30. for i:=1 to 4 do
  31. if s[i,j]='X' then c:=c+a[5-j,i];
  32.  
  33. write(c);
  34. end.
Success #stdin #stdout 0.01s 256KB
stdin
....
X..X
.X..
...X
Pwoo
Khaa
smrs
odbk
stdout