|
|
back to boardPascal?????в чем ошибка? Posted by Nastya 19 Dec 2017 12:57 program m; var a:array[1..4000] of integer; p:array[1..4000] of integer; x:array[1..4000] of integer; n,s,i,j,k,f,m:integer; begin read(n); for i:=1 to n do read(a[i]); read(s); for j:=1 to s do read(p[j]); read(k); for f:=1 to k do read(x[f]);m:=0; for i:=1 to n do for j:=1 to s do for f:=1 to k do begin if (a[i]=p[j]) and (p[j]=x[f]) and (x[f]=a[i]) then m:=m+1; end; write(m); end. Re: Pascal?????в чем ошибка? Your algo has complexity O(n1*n2*n3) id est 4000*4000*4000= 6.4*10^10. It's too much operations for one half a second. Try to use other algo instead of linear search twice. |
|
|