Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. uses
  2. sysutils, math;
  3. const
  4. eps = 1e-8;
  5. maxn = 1000;
  6.  
  7. var
  8. z: array[1..maxn] of boolean;
  9. a: array[1..maxn, 1..maxn] of boolean;
  10. r: array[1..maxn] of integer;
  11. n: integer;
  12.  
  13. function go(i: integer): boolean;
  14. var
  15. j: integer;
  16. begin
  17. if z[i] then begin
  18. go := false;
  19. end else begin
  20. z[i] := true;
  21. for j := 1 to n do if a[i, j] and (r[j] <> i) then begin
  22. if r[j] = 0 then begin
  23. go := true;
  24. r[j] := i;
  25. exit;
  26. end else begin
  27. if go(r[j]) then begin
  28. go := true;
  29. r[j] := i;
  30. exit;
  31. end;
  32. end;
  33. end;
  34. go := false;
  35. end;
  36. end;
  37.  
  38. var
  39. v, i, j, k: integer;
  40. ch: char;
  41. t, x, y: array[1..maxn] of integer;
  42.  
  43. begin
  44. reset(input, 'input.txt');
  45. rewrite(output, 'output.txt');
  46. read(n, v);
  47. for i := 1 to n do
  48. begin
  49. if not seekeof then read(ch);
  50. j := strtoint(ch);
  51. read(ch);
  52. j := j * 10 + strtoint(ch);
  53. read(ch);
  54. assert(ch = ':');
  55. read(ch);
  56. j := j * 6 + strtoint(ch);
  57. read(ch);
  58. j := j * 10 + strtoint(ch);
  59. t[i] := j;
  60. read(x[i], y[i]);
  61. end;
  62.  
  63. for i := 1 to n do begin
  64. for j := 1 to n do if (i <> j) then begin
  65. if (t[j] - t[i]) * v / 60 >= hypot(x[i] - x[j], y[i] - y[j]) - eps then
  66. a[i, j] := true
  67. else
  68. a[i, j] := false;
  69. end;
  70. end;
  71.  
  72. fillchar(r, sizeof(r), 0);
  73.  
  74. k := 0;
  75. for i := 1 to n do begin
  76. fillchar(z, sizeof(z), 0);
  77. if go(i) then inc(k);
  78. end;
  79.  
  80.  
  81. writeln(n - k);
  82.  
  83. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement