Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Project1;
- {$APPTYPE CONSOLE}
- uses
- SysUtils;
- const
- MAXIN = 1000;
- var
- n, m, i, j, k, p, x, y: integer;
- a, b: array [1..MAXIN] of integer;
- bol, bol1: boolean;
- begin
- readln(n, m);
- for i := 1 to n do
- read(a[i]);
- for i := 1 to m do
- read(b[i]);
- readln(k);
- p := 0;
- for i := 1 to k do
- begin
- bol := false;
- bol1 := false;
- readln(x, y);
- for j := 1 to n do
- if (x = a[i]) or (y = a[i]) then
- bol := true;
- for j := 1 to m do
- if (x = b[i]) or (y = b[i]) then
- bol1 := true;
- if (bol) and (bol1) then
- inc(p);
- end;
- writeln(p);
- readln;
- readln;
- end.
Advertisement
Add Comment
Please, Sign In to add comment