# ZOJ2532[Internship]

CODE:

/*

AUTHOR: Su Jiao

DATE: 2010-7-20

DESCRIPTION:

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1532

*/

#include <stdio.h>

#include <string.h>

const int oo=(~0u)>>1;

const int MAXV=1000000;

const int MAXE=1000000;

typedef struct struct_edge* edge;

struct struct_edge{int v,c;edge n,b;};

struct_edge pool[MAXE];

edge top;

int S,T,V;

int d[MAXV];

int q[MAXV];

{

}

bool relabel()

{

for (int i=0;i<V;d[i++]=oo) ;

{

if (i->b->c&&d[i->v]==oo)

d[q[++tail]=i->v]=d[u]+1;

if (d[S]!=oo) return true;

}

return false;

}

int augment(int u,int e)

{

if (u==T) return e;

int f=0;

if (i->c&&d[u]==d[i->v]+1)

if (int df=augment(i->v,e<i->c?e:i->c))

i->c-=df,i->b->c+=df,e-=df,f+=df;

return f;

}

int dinic()

{

int f=0;

while (relabel()) f+=augment(S,oo);

return f;

}

const int MAXL=1000;

int n,m,l;

int a[MAXL],b[MAXL],c[MAXL];

int main()

{

for (;;)

{

scanf(“%d%d%d”,&n,&m,&l);

if (!n) break;

top=pool;

S=n+m+1,T=0,V=n+m+2;

for (int i=0;i<l;i++)

scanf(“%d%d%d”,a+i,b+i,c+i),

for (int i=1;i<=n;i++)

int flow=dinic();

bool first=true;

for (int i=0;i<l;i++)

{

if (relabel()) if (first) printf(“%d”,i+1),first=false;

else printf(” %d”,i+1);

}

printf(“\n”);

}

}