记录编号 |
20763 |
评测结果 |
AWWWWWWWWW |
题目名称 |
罪犯问题D |
最终得分 |
10 |
用户昵称 |
wo shi 刘畅 |
是否通过 |
未通过 |
代码语言 |
Pascal |
运行时间 |
2.335 s |
提交时间 |
2010-10-29 10:28:37 |
内存使用 |
76.98 MiB |
显示代码纯文本
var
i,n,m,xx,yy,y,p:longint;
ch:char;
a,b:Array[0..50001,0..200]of longint;
g:Array[0..50001]of longint;
procedure go(x:longint);
var
ju,o,i:longint;
begin
ju:=-1*g[x];
for i:=1 to b[x,0] do
if g[b[x,b[x,0]]]=0 then
begin
g[b[x,b[x,0]]]:=a[x,a[x,0]]*ju;
go(b[x,b[x,0]]);
end;
end;
procedure init(xx,y:longint);
var
yy:longint;
begin
inc(a[xx,0]);
if y<0 then a[xx,a[xx,0]]:=-1
else a[xx,a[xx,0]]:=1;
inc(b[xx,0]);
b[xx,b[xx,0]]:=abs(y);
yy:=abs(y);
inc(a[yy,0]);
if y<0 then a[yy,a[yy,0]]:=-1
else a[yy,a[yy,0]]:=1;
inc(b[yy,0]);
b[yy,b[yy,0]]:=xx;
end;
begin
assign(input,'criminald.in'); reset(input);
assign(output,'criminald.out'); rewrite(output);
readln(n,m);
for i:=1 to m do
begin
read(xx);
g[xx]:=1;
end;
readln;
repeat
read(ch);
case ch of
'A':
begin
readln(xx);
if g[xx]=1 then writeln('Yes');
if g[xx]=0 then writeln('Unknown');
if g[xx]=-1 then writeln('No');
end;
'S':
begin
readln(xx,y);
if (g[xx]<>0)and(g[abs(y)]=0) then
begin
if (g[xx]=-1)and(y<0) then g[abs(y)]:=-1;
if (g[xx]=-1)and(y>0) then g[abs(y)]:=1;
if (g[xx]=1)and(y<0) then g[abs(y)]:=1;
if (g[xx]=1)and(y>0) then g[abs(y)]:=-1;
go(abs(y));
end
else if (g[xx]=0)and(g[abs(y)]<>0) then
begin
if (g[abs(y)]=-1)and(y>0) then g[xx]:=1;
if (g[abs(y)]=-1)and(y<0) then g[xx]:=-1;
if (g[abs(y)]=1)and(y>0) then g[xx]:=-1;
if (g[abs(y)]=1)and(y<0) then g[xx]:=1;
go(xx);
end
else if (g[xx]=0)and(g[abs(y)]=0) then
init(xx,y);
end;
end;
until ch='E';
close(input);
close(output);
end.