简单模拟题,不过要注意同一个字母加密后的字母是一样的,加密后一样的字母原字母也是一样的。
program spy;
var
a,b:array['A'..'Z'] of char;
s1,s2,s:string;
i,k,k1:integer;
j:char;
procedure print;
begin
writeln('Failed');
close(input);
close(output);
halt;
end;
begin
assign(input,'spy.in');
reset(input);
assign(output,'spy.out');
rewrite(output);
readln(s1);
readln(s2);
readln(s);
if length(s1)<26 then print;
for j:='A' to 'Z' do
begin
a[j]:=' ';
b[j]:=' ';
end;
k:=26;
k1:=26;
for i:=1 to length(s1) do
begin
if a[s2[i]]=' ' then
begin
a[s2[i]]:=s1[i];
dec(k);
end
else if a[s2[i]]<>s1[i] then print;
if b[s1[i]]=' ' then
begin
b[s1[i]]:=s2[i];
dec(k1);
end
else if b[s1[i]]<>s2[i] then print;
end;
if (k>0) or (k1>0) then print;
for i:=1 to length(s) do
write(b[s[i]]);
close(input);
close(output);
end.