|
|
back to boardNo subject It`s wrong on 32 test. I can`t understand the problem. I used bin search. const n0=10000; type u = array[1..n0] of integer; var a:u; b:u; c:u; n,i,k,l,m,j,q,t:integer; function bin_search(s,n:integer; var mas:u):integer; var ib,im,i1:integer; begin i1:=1; ib:=n; while i1<=ib do begin im:=i1+(ib-i1) div 2; if mas[im] = s then begin bin_search:=s; break; end else if mas[im] < s then i1:=im+1 else ib:=im-1; end; if i1>ib then bin_search:=-1; end; begin readln(n); for i:=1 to n do read(a[i]); readln(k); for l:=1 to k do read(b[l]); readln(m); for j:=1 to m do read(c[j]);
for t:=1 to m do begin if bin_search(c[t],m,b)<>-1 then if bin_search(c[t],m,a)<>-1 then q:=q+1; end; writeln(q); end. Edited by author 25.11.2015 10:20 |
|
|