/ Vijos / 讨论 / Knights /

6——10点什么情况

我的程序过不了也就认了,但是连标程都过不了就不科学了!!!如果数据没错,我的哪里错了?
program p1729;
var
where,where1,where2:array[0..1000,1..2] of longint;
aimy:array[0..1000] of longint;
bi:array[0..1000,0..1000] of boolean;
x,y:array[0..1000] of boolean;
n,m,n1,n2,i,j,ans:longint;
s:string;
function find(k:longint):boolean;
var
i,j:longint;
begin
x[k]:=false;
for i:=1 to n2 do
if (y[i]) and (bi[k,i]) then begin
y[i]:=false;
if (aimy[i]=0) or (find(aimy[i])) then begin
aimy[i]:=k;
exit(true);
end;
end;
exit(false);
end;{
function pd(k:longint):boolean;
begin
if (where[k,1]>m) or (where[k,1]<1) then exit(false);
if (where[k,2]>m) or (where[k,2]<1) then exit(false);
exit(true);
end;}
begin
readln(m,n);
n1:=0;n2:=0;
for i:=1 to n do begin
readln(s);
where[i,1]:=ord(s[1])-ord('A')+1;
where[i,2]:=ord(s[2])-ord('0');
if (where[i,1]+where[i,2]) mod 2=0 then begin
inc(n1);
where1[n1,1]:=where[i,1];
where1[n1,2]:=where[i,2];
end else begin
inc(n2);
where2[n2,1]:=where[i,1];
where2[n2,2]:=where[i,2];
end;
end;
{for i:=1 to n do
writeln(where[i,1],' ',where[i,2]);}
fillchar(bi,sizeof(bi),false);
for i:=1 to n1 do
for j:=1 to n2 do
if (abs(where1[i,1]-where2[j,1])+abs(where1[i,2]-where2[j,2])=3) and (abs(abs(where1[i,1]-where2[j,1])-abs(where1[i,2]-where2[j,2]))=1) { and (pd(i)) and (pd(j))} then
bi[i,j]:=true;
{for i:=1 to n do begin
for j:=1 to n do
write(bi[i,j],' ');
writeln;
end;}
fillchar(aimy,sizeof(aimy),0);
ans:=0;
for i:=1 to n1 do begin
fillchar(y,sizeof(y),true);
fillchar(x,sizeof(x),true);
if find(i) then inc(ans);
end;
writeln(ans);
readln;
readln;
end.

0 条评论

目前还没有评论...

信息

ID
1729
难度
7
分类
图结构 | 二分图匹配 点击显示
标签
(无)
递交数
720
已通过
152
通过率
21%
被复制
3
上传者