测评机: Xeost[5]
得分: 0分
提交日期: 2012-2-3 10:37:00
有效耗时: 该状态没有记录
测试结果1: 选手程序无输出
测试结果2: 选手程序无输出
测试结果3: 选手程序无输出
测试结果4: 选手程序无输出
测试结果5: 选手程序无输出
测试结果6: 选手程序无输出
测试结果7: 选手程序无输出
测试结果8: 选手程序无输出
测试结果9: 选手程序无输出
测试结果10: 选手程序无输出
var i,j,m,n,p,x,y,get,max:longint;ss,n1,n2:string;
f,a:array[0..5000000]of longint;
name:array[0..5000000]of string;
function getfather(x:longint):longint;
begin
if f[x]=0 then getfather:=x else
begin
f[x]:=getfather(f[x]);
getfather:=f[x];
end;
end;
procedure work(x,y:longint);
var xx,yy:longint;
begin
xx:=getfather(x);yy:=getfather(y);
if (xx=yy)and(xx<>0) then exit
else f[xx]:=yy;
end;
begin
readln(n,m,p);
for i:=1 to n do readln(name[i]);
for i:=1 to m do
begin
readln(ss);
n1:=copy(ss,1,pos(' ',ss)-1);
n2:=copy(ss,pos(' ',ss)+1,length(ss)-length(n1)-1);
for j:=1 to n do
if name[j]=n1 then x:=j
else if name[j]=n2 then y:=j;
work(x,y);
end;
for i:=1 to p do
begin
readln(ss);
n1:=copy(ss,1,pos(' ',ss)-1);
n2:=copy(ss,pos(' ',ss)+1,length(ss)-length(n1)-1);
for j:=1 to n do
if name[j]=n1 then x:=j
else if name[j]=n2 then y:=j;
if (getfather(x)=getfather(y)) then writeln('safe') else writeln('cc cry');
end;
end.