11 int edges
[NN
][NN
*2], deg
[NN
], cap
[NN
][NN
];
13 void addEdge(int from
, int to
, int C
, int flow
){
14 edges
[from
][deg
[from
]++] = to
;
16 edges
[to
][deg
[to
]++] = from
;
18 int dinic(int s
, int t
){
21 memset(prev
, -1, sizeof(prev
));
23 prev
[q
[qe
++] = s
] = -2;
24 while( qb
< qe
&& prev
[t
] == -1 )
25 for(int u
= q
[qb
++], v
, i
= 0;i
<deg
[u
]; i
++ )
26 if( prev
[v
=edges
[u
][i
]] == -1 && cap
[u
][v
] )prev
[q
[qe
++] = v
] = u
;
28 if( prev
[t
] == -1 ) break;
30 for(int z
= 0; z
< t
; z
++ )if( cap
[z
][t
] && prev
[z
] != -1 ){
32 for(int u
= t
, v
= prev
[u
]; u
!= v
; u
= v
, v
= prev
[u
])
33 mf
= min ( mf
, cap
[v
][u
] );
35 for(int u
= t
, v
= prev
[u
]; u
!= v
; u
= v
, v
= prev
[u
])
36 cap
[v
][u
] -= mf
, cap
[u
][v
] += mf
;
44 while(scanf("%i", &N
)!=EOF
){
45 memset(deg
, 0, sizeof(deg
));
46 memset(cap
, 0, sizeof(cap
));
49 addEdge(i
+1, i
+1+N
,k
,0);
54 scanf("%i %i %i", &a
, &b
, &c
);
58 scanf("%i %i", &B
, &D
);
65 addEdge(N
+c
,2*N
+1,INF
,0);
67 // printf("%i\n", indice);
68 int flow
= dinic(0,2*N
+1);