var x,y:array[0..110000] of string;
    i,n,l,r,mid:longint;
    s:string;
procedure qsort(h,l:longint);
 var i,j:longint;
     temp,m:string;
 begin
 i:=h;j:=l;m:=x[(i+h)>>1];
 repeat
  while x[i]<m do inc(i);
  while x[j]>m do dec(j);
  if i<=j then
   begin
    temp:=x[i];x[i]:=x[j];x[j]:=temp;
    temp:=y[i];y[i]:=y[j];y[j]:=temp;
    inc(i);dec(j);
   end;
 until i>j;
 if i<l then qsort(i,l);
 if j>h then qsort(h,j);
 end;
procedure init;
 begin
 n:=0;
 while true do
  begin
  readln(s);if s='' then break;
  inc(n);
  y[n]:=copy(s,1,pos(' ',s)-1);
  delete(s,1,pos(' ',s));
  x[n]:=s;
  end;
 qsort(1,n);
 end;
procedure main;
 begin
 while true do
  begin
  readln(s);if s='' then break;
  l:=1;r:=n;
  while l<r do
   begin
   mid:=(l+r)>>1;
   if s<x[mid] then r:=mid
   else if s>x[mid] then l:=mid+1
   else begin l:=mid;r:=mid;end;
   end;
  if x[l]=s then writeln(y[l]) else writeln('eh');
  end;
 end;
begin
 init;
 main;
end.    
View Code

相关文章:

  • 2021-11-14
  • 2022-12-23
  • 2021-07-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-02
  • 2021-05-20
  • 2021-09-25
  • 2021-05-30
  • 2022-02-14
相关资源
相似解决方案