Dennnhhhickk

Untitled

Oct 7th, 2016
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. program Project1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6. SysUtils;
  7.  
  8. const
  9. MAXIN = 1000;
  10.  
  11. var
  12. n, m, i, j, k, p, x, y: integer;
  13. a, b: array [1..MAXIN] of integer;
  14. bol, bol1: boolean;
  15.  
  16. begin
  17. readln(n, m);
  18.  
  19. for i := 1 to n do
  20. read(a[i]);
  21.  
  22. for i := 1 to m do
  23. read(b[i]);
  24.  
  25. readln(k);
  26. p := 0;
  27.  
  28. for i := 1 to k do
  29. begin
  30. bol := false;
  31. bol1 := false;
  32. readln(x, y);
  33. for j := 1 to n do
  34. if (x = a[i]) or (y = a[i]) then
  35. bol := true;
  36. for j := 1 to m do
  37. if (x = b[i]) or (y = b[i]) then
  38. bol1 := true;
  39. if (bol) and (bol1) then
  40. inc(p);
  41. end;
  42.  
  43. writeln(p);
  44. readln;
  45. readln;
  46. end.
Advertisement
Add Comment
Please, Sign In to add comment