思路:最大流 建立超级源点src 与5种衣服相连 边权为衣服的数量 超级汇点与xn个人相连 边权为1
然后每个人与自己相应的尺码间也建立一条边,边权为1 求最大流 等于 xn 就输出
反之 I'd rather not wear a shirt anyway...
下面代码很怪,用codeblocks 运行不出来正确答案 用vc就OK 啥原因不明。。。。 = =||
//388K
0MS
#include <stdio.h>
#include <string.h>
#define VM 30
#define EM 300
const int inf = 0x3f3f3f3f;
struct E
{
to,cap,nxt;
} edge[EM];
int head[VM],dep[VM],cur[VM],pre[VM],gap[VM];
int e,N,x,src,des;
void addedge (int cu,int cv,int cw)
{
cv;
= cw;
= head[cu];
++;
cu;
= 0;
= head[cv];
++;
}
void Init() 建图
{
i,x1,x2,num;
s2[5];
("%d",&x);
//x是人数
= x + 6;
1;
//总的点数 两超级点 + xn个人+ 5种型号衣服
<= x;i ++)
scanf ("%s",s2);
if (s2[0] == 'S')
x1 = x + 1;
if (s2[0] == 'M')
x1 = x + 2;
if (s2[0] == 'L')
x1 = x + 3;
if (s2[0] == 'X')
x1 = x + 4;
if (s2[0] == 'T')
x1 = x + 5;
if (s2[1] == 'S')
x2 = x + 1;
if (s2[1] == 'M')
x2 = x + 2;
if (s2[1] == 'L')
x2 = x + 3;
if (s2[1] == 'X')
x2 = x + 4;
if (s2[1] == 'T')
x2 = x + 5;