📄 ac1162.pas
字号:
program tju1162;
const
maxn=200;
var
root:array[1..sqr(maxn)]of word;
n,m,i,x,y:word;
c:char;
procedure pathcomp(x:word);
var
r,t:word;
begin
r:=x;while root[r]<>r do r:=root[r];
while x<>r do begin t:=root[x];root[x]:=r;x:=t;end;
end;
procedure test;
begin
read(n,m);
for i:=1 to sqr(n) do root[i]:=i;
for i:=1 to m do begin
read(x,y);x:=(x-1)*n+y;
readln(c,c);if c='D' then y:=x+n else y:=x+1;
pathcomp(x);pathcomp(y);
if root[x]=root[y] then begin
for x:=i+1 to m do readln;writeln(i);exit;
end
else
root[root[x]]:=root[y];
end;
writeln('draw');
end;
begin
repeat
test;
until seekeof;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -