CHEFDAG Video Solution

Anyone please help me with finding what is wrong in my code for CHEF DAG.I have spend hours in this.Please help me find a bug.
Solution link:-CodeChef: Practical coding for everyone

hey why we need to store the reverse flow for an edge in the residual graph even if this edge is a directed one from x to y ?
doubt regarding the max flow in a DAG.
plz help me i m confused!

@everule1 hey can you plz tell me why you said that it is optimall to have every node max 1 parent.As it is said in the question outdegree should be max 1 which itself says that max 1 children they have . Lets consider this example
3 2
1 2 3
2 1 3

if we take parent should be max 1 then answer should be 3 0 0
but if we take children should be 1 then ans should be 3 3 0 .

Yes, but 2 nodes still have indegree 0. We have to minimise the number of nodes with indegree 0.

1 Like

@everule1 Ohh thanks I misunderstood question as I was just consider to minimize the 0 in the array instead what you said above .Now I understood thanks…

hey bro! when are u posting the official editorial??

During contest I was unable to generate such permutation.
but now I have generates such permutation which gives wrong answer :sweat_smile:

Here it is
1
7 4
3 7 5 6 1 2 4
3 5 6 7 1 4 2
1 4 5 2 3 6 7
1 5 2 4 3 7 6

My answer is
5
2 0 6 0 6 0 0

while the correct ans is
4
4 0 6 0 2 0 0

Thank you