记录编号 |
22921 |
评测结果 |
AAAAAAAAAA |
题目名称 |
总流量 |
最终得分 |
100 |
用户昵称 |
苏轼 |
是否通过 |
通过 |
代码语言 |
C |
运行时间 |
0.006 s |
提交时间 |
2011-01-09 13:31:44 |
内存使用 |
0.24 MiB |
显示代码纯文本
#include <stdio.h>
#define id(X) (X<'a' ? X-'A' : X-'a'+26)
#define min(X,Y) ((X)>(Y)?(Y):(X))
#define MAXN 10000
#define bool char
#define true 1
#define false 0
short way[52][52],up;
bool boo[52];
short go(short wh,short flow)
{
if (wh==25)
return flow;
short fl=flow,tmp,i;
boo[wh]=true;
for (i=0; i<up; i++)
if (way[wh][i] && !boo[i])
{
tmp=go(i,min(way[wh][i],fl));
way[wh][i]-=tmp;
way[i][wh]+=tmp;
fl-=tmp;
if (fl==0)
break;
}
boo[wh]=false;
return flow-fl;
}
int main(void)
{
FILE *fin=fopen("tflow.in","r");
FILE *fout=fopen("tflow.out","w");
char ca,cb;
short n,f,i;
fscanf(fin,"%hd\n",&n);
for (i=0; i<n; i++)
{
fscanf(fin,"%c %c %hd\n",&ca,&cb,&f);
int a=id(ca),b=id(cb);
way[a][b]+=f;
way[b][a]+=f;
if (a>up || b>up)
up=a>b ? a:b;
}
up++;
fprintf(fout,"%hd\n",go(0,MAXN));
fclose(fin);
fclose(fout);
return 0;
}