比赛 |
20101224 |
评测结果 |
AAAAAAAAAA |
题目名称 |
总流量 |
最终得分 |
100 |
用户昵称 |
ybh |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-12-24 20:18:14 |
显示代码纯文本
{总流量
Author: yangbohua
Time: 2010-12-24}
program tflow;
var
limit:array[0..100,0..100] of longint;
d,vd:array[0..100] of longint;
n,m,i,temp1,temp2,r1,maxflow:longint;
r:char;
function min(a,b:longint):longint;
begin
if a>b
then min:=b
else min:=a;
end;
function dfs(u,flow:longint):longint;
var
v,tmp,dfs2:longint;
begin
if u=n
then exit(flow);
dfs2:=0;
for v:=1 to 52 do
begin
if (limit[u,v]>0) and (d[u]=d[v]+1) then
begin
tmp:=dfs(v,min(flow-dfs2,limit[u,v]));
dec(limit[u,v],tmp);
inc(limit[v,u],tmp);
dfs2:=dfs2+tmp;
if dfs2=flow then exit(flow);
end;
end;
if d[1]>=n
then exit(dfs2);
dec(vd[d[u]]);
if vd[d[u]]=0
then d[1]:=n;
inc(d[u]);
inc(vd[d[u]]);
dfs:=dfs2;
end;
begin
assign(input,'tflow.in');
reset(input);
assign(output,'tflow.out');
rewrite(output);
fillchar(limit,sizeof(limit),0);
readln(m);
for i:=1 to m do
begin
read(r);
if (r>='A') and (r<='Z') then
begin
temp1:=ord(r)-ord('A')+1;
end;
if (r>='a') and (r<='z') then
begin
temp1:=ord(r)-ord('a')+1+26;
end;
read(r);
read(r);
if (r>='A') and (r<='Z') then
begin
temp2:=ord(r)-ord('A')+1;
end;
if (r>='a') and (r<='z') then
begin
temp2:=ord(r)-ord('a')+1+26;
end;
readln(r1);
if temp1=26 then temp1:=52
else if temp1=52 then temp1:=26;
if temp2=26 then temp2:=52
else if temp2=52 then temp2:=26;
inc(limit[temp1,temp2],r1);
inc(limit[temp2,temp1],r1);
end;
n:=52;
vd[0]:=n;
maxflow:=0;
while d[1]<n do
inc(maxflow,dfs(1,maxlongint));
writeln(maxflow);
close(input);
close(output);
end.