a:array[0..1000000]of string;
n,m,t,i,j:longint;
s:string;
p:boolean;procedure kp(i,j:longint);var
l,r:longint;
mid:string;begin
l:=i;
r:=j;
mid:=a[(i+j)div 2]; repeat
while a[i]<mid do inc(i); while a[j]>mid do dec(j); if i<=j then
begin
a[0]:=a[i];
a[i]:=a[j];
a[j]:=a[0];
inc(i);
dec(j); end; until i>j; if l<j then kp(l,j); if i<r then kp(i,r);end;procedure jb(i,j:longint);var
k:longint;begin
if i>j then exit;
k:=(i+j)div 2; if a[k]=s then
begin
p:=true; exit; end; if s<a[k] then jb(i,k-1) else jb(k+1,j);end;begin
readln(n); for i:=1 to n do readln(a[i]);
kp(1,n);
readln(m); for j:=1 to m do
begin
readln(s);
p:=false;
jb(1,n); if p then writeln('Yes')else writeln('No'); end;end.
滿分答案,麻煩采納,謝謝!