比赛 |
20091110 |
评测结果 |
AAAAAAAAAA |
题目名称 |
查字典 |
最终得分 |
100 |
用户昵称 |
rottenwood |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2009-11-10 10:41:43 |
显示代码纯文本
program scanword;
var
s,aim:array[1..10000] of string;
f:array[1..10000] of longint;
i,j,k,m,n,ans,wocao:longint;
procedure cz(mb:string;l,r:longint);
var i,j:longint;
begin
j:=(l+r) div 2;
if (mb<>s[j])and(mb<s[j]) then cz(mb,l,j)
else if (mb<>s[j])and(mb>s[j]) then cz(mb,j+1,r)
else if mb=s[j] then wocao:=f[j];
end;
procedure qsort(l,r:longInt);
var
i,j,x,y:longint; s1,ss:string;
begin
i:=l; j:=r; ss:=s[(l+r) div 2];
repeat
while s[i]<ss do i:=i+1;
while ss<s[j] do j:=j-1;
if i<=j then
begin
y:=f[i]; f[i]:=f[j]; f[j]:=y;
s1:=s[i];s[i]:=s[j]; s[j]:=s1;
i:=i+1; j:=j-1;
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
assign(input,'scanword.in');reset(input);
assign(output,'scanword.out');rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(s[i]);
readln(f[i]);
end;
readln(m);
for i:=1 to m do readln(aim[i]);
qsort(1,n);
for i:=1 to m do
begin
cz(aim[i],1,n);
ans:=wocao;
writeln(ans);
end;
close(output);
end.