poj 2584 T-Shirt Gumbo(最大流 s…
来源:互联网 发布:ar9565 linux 编辑:程序博客网 时间:2024/05/26 12:57
题意:有xn个参赛者,给出每个参赛者所需要的衣服的尺码的大小范围,在该尺码范围内的衣服该选手可以接受,给出这5种型号衣服各自的数量,问是否存在一种分配方案使得每个选手都能够拿到自己尺码范围内的衣服.
思路:最大流 建立超级源点src 与5种衣服相连 边权为衣服的数量 超级汇点与xn个人相连 边权为1然后每个人与自己相应的尺码间也建立一条边,边权为1 求最大流 等于 xn 就输出 T-shirts rock!反之 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
{
intto,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)
{
edge[e].to =cv;
edge[e].cap= cw;
edge[e].nxt= head[cu];
head[cu] = e++;
edge[e].to =cu;
edge[e].cap= 0;
edge[e].nxt= head[cv];
head[cv] = e++;
}
void Init() 建图
{
inti,x1,x2,num;
chars2[5];
scanf("%d",&x); //x是人数
src = 0,des= x + 6;
N = des +1; //总的点数 两超级点 + xn个人+ 5种型号衣服
for (i = 1;i<= 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;
思路:最大流 建立超级源点src 与5种衣服相连 边权为衣服的数量 超级汇点与xn个人相连 边权为1然后每个人与自己相应的尺码间也建立一条边,边权为1 求最大流 等于 xn 就输出
下面代码很怪,用codeblocks 运行不出来正确答案 用vc就OK 啥原因不明。。。。 = =||
//388K
#include <stdio.h>
#include <string.h>
#define VM 30
#define EM 300
const int inf = 0x3f3f3f3f;
struct E
{
} 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)
{
}
void Init() 建图
{