Dennnhhhickk

Untitled

Oct 13th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. const
  9. MAXIN = 1000;
  10.  
  11. var
  12. n, m, i, j, x1, y, z: integer;
  13. x: extended;
  14. a, b: array [0..MAXIN] of extended;
  15. bol: array [0..MAXIN] of boolean;
  16. check: array [0..MAXIN, 0..MAXIN] of boolean;
  17.  
  18. begin
  19. readln(n, m);
  20.  
  21. for i := 1 to n do
  22. begin
  23. bol[i] := true;
  24. a[i] := 0;
  25. b[i] := i;
  26. for j := 1 to n do
  27. check[i][j] := true;
  28. end;
  29.  
  30. for i := 1 to m do
  31. begin
  32. read(x1, y);
  33. check[x1][y] := false;
  34. if (y = 0) then
  35. begin
  36. bol[x1] := false;
  37. end;
  38. if (bol[x1]) then
  39. begin
  40. read(z);
  41. if (z = 1) then
  42. a[x1] := a[x1] + 1
  43. else
  44. if (z = 2) then
  45. a[y] := a[y] + 1
  46. else
  47. begin
  48. a[x1] := a[x1] + 0.5;
  49. a[y] := a[y] + 0.5;
  50. end;
  51. end;
  52. end;
  53.  
  54. for i := 1 to n - 1 do
  55. for j := i + 1 to n do
  56. if (check[i][j]) and (bol[i]) and not(bol[j]) then
  57. a[i] := a[i] + 1
  58. else
  59. if (check[i][j]) and not(bol[i]) and (bol[j]) then
  60. a[j] := a[j] + 1
  61. else
  62. if (check[i][j]) and (bol[i]) and (bol[j]) then
  63. begin
  64. a[i] := a[i] + 0.5;
  65. a[j] := a[j] + 0.5;
  66. end;
  67.  
  68. for i := 2 to n do
  69. for j := n downto i do
  70. if (a[j] > a[j - 1]) then
  71. begin
  72. x := a[j];
  73. a[j] := a[j - 1];
  74. a[j - 1] := x;
  75. x := b[j];
  76. b[j] := b[j - 1];
  77. b[j - 1] := x;
  78. end;
  79.  
  80. for i := 1 to n do
  81. writeln(b[i]:0:0, ' ', a[i]:0:1);
  82.  
  83. readln;
  84. readln;
  85. end.
Advertisement
Add Comment
Please, Sign In to add comment