SHARE
TWEET

Untitled

a guest Oct 19th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program colors;
  2. var FirstHill,SecondHill:integer;
  3. var Colours: array of integer;
  4. var BridgesBetwenHills: array [,] of integer;
  5. var i,j,a,b,c:integer;
  6. var n,IncorrectBriges:integer;
  7. begin
  8. Readln(n);
  9. SetLength(Colours,n);
  10. SetLength(BridgesBetwenHills,n,n);
  11. for i:=0 to (n-1) do
  12.  begin
  13.  for j:=0 to (n-1) do
  14.   begin
  15.   read(BridgesBetwenHills[i,j]);
  16.   Write(' ');
  17.   end;
  18.   Writeln();
  19.  end;
  20. Writeln();
  21. for a:=0 to n-1 do
  22.  begin
  23.  Read(Colours[a]);
  24.  end;
  25. for b:=1 to n-1 do
  26.  begin
  27.  FirstHill:=Colours[b-1];
  28.  SecondHill:=Colours[b];
  29.  if not(SecondHill = FirstHill) then
  30.   begin
  31.   for c:=0 to n-1 do
  32.    begin
  33.    IncorrectBriges:= IncorrectBriges + BridgesBetwenHills[b,c]+ BridgesBetwenHills[b-1,c];
  34.    end;
  35.   end;
  36.  end;
  37. Writeln(IncorrectBriges);
  38. end.
  39. {7
  40. 0 1 0 0 0 1 1
  41. 1 0 1 0 0 0 0
  42. 0 1 0 0 1 1 0
  43. 0 0 0 0 0 0 0
  44. 0 0 1 0 0 1 0
  45. 1 0 1 0 1 0 0
  46. 1 0 0 0 0 0 0
  47.  
  48. 1 1 1 1 1 3 3}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top