- Knights
- 2012-09-23 12:57:27 @
目测代码应该没什么问题啊= =
var
s:array [1..26*26,1..2] of longint;
n,i,j,t:longint;
m:longint;
ch1,ch2:char;
str:string;
best,total:longint;
line:array [1..200000,1..2] of longint;
link:array [1..20000] of longint;
vis:array [1..20000] of boolean;
map:array [1..20000] of longint;
function dfs(x:longint):boolean;
var
p,node:longint;
begin
p:=map[x];
vis[x]:=true;
while p-1 do
begin
node:=line[p,1];
if ( link[node]=0) or ( (not vis[link[node]]) and (dfs(link[node])) ) then
begin
link[node]:=x;
exit(true);
end;
p:=line[p,2];
end;
exit(false);
end;
procedure make(a,b:longint);
begin
inc(total);
line[total,1]:=b;
line[total,2]:=map[a];
map[a]:=total;
end;
begin
readln(m,n);best:=0;
fillchar(map,sizeof(map),$ff);
for i:=1 to n do
begin
read(str);
s:=ord(str[1])-ord('A')+1;
delete(str,1,1);
val(str,s);
readln;
end;
for i:=1 to n do
begin
if (s+s) mod 2=0 then
for j:=1 to n do
begin
if ( (abs(s-s[j,1])=1) and (abs(s-s[j,2])=2) ) or
( (abs(s-s[j,1])=2) and (abs(s-s[j,2])=1) ) then
begin
make(i,j);
end;
end;
end;
for i:=1 to n do
begin
if (s+s) mod 2=0 then
begin
fillchar(vis,sizeof(vis),false);
if dfs(i) then inc(best);
end;
end;
writeln(best);
end.
求大牛帮忙。。
5 条评论
-
ljq LV 10 @ 2012-09-23 20:00:53
数据已经修改。
-
2012-09-23 13:30:33@
不好意思,第一个测试点有点问题。我们将会更正数据。
另外,本次比赛的程序将会重测,选手的成绩可能会发生变化。 -
2012-09-23 13:03:50@
AC的都是C++的……
-
2012-09-23 13:02:52@
。。。不至于这么坑爹吧。。楼上= =
RT
-
2012-09-23 13:01:25@
第一个点
我也是第一个点过不了,是不是c与pascal的输入差异,而数据行末又有问题呢?
- 1