ShadowAA @ 2017-11-12 11:34:04
var n,m,i,j,x,y,max:longint;
a:array[0..1001]of string;
b,c:array[0..1001]of longint;
s:string;
begin
readln(n,m);
for i:=1 to n do
begin
readln(a[i]);
val(a[i],c[i]);
b[i]:=length(a[i]);
end;
for i:=1 to m do
begin
readln(x,y);
str(y,s);
max:=maxlongint;
for j:=1 to n do
if (b[j]>=x) and (c[j]<max) and (pos(s,a[j])=b[j]-x+1) then
max:=c[j];
if max=maxlongint then
writeln(-1)
else
writeln(max);
end;
end.
by wangxiaoyi1118 @ 2024-10-11 13:05:49
烤谷qp