Problem with Chef and Bipartite Graphs ICPC16F

I’m getting wrong answer for the problem Chef and Bipartite graphs ICPC16F. Can anybody provide input for which it will fail ?

Thanks in advance.

Question Link:

Code Link:


I too have same doubt.

CodeLink :


I have the same doubt.



I have serious doubt in this question.



It gives correct output for all the above codes. Please run the codes and verify.

@nmalviya1929 I couldn’t figure out a failing test case but your code will definitely give a TLE for large subtasks (n=100,m=10000) as it uses slow I/O operations.

Why are they not opening question for practice???.If anyone knows where they are,Please tell me the link…

@ankesh18 The time limit for the problem was 2 seconds and using 10^6 I/O operations will never give TLE verdict. Further I was getting WA Verdict not TLE.

1 Like

@codelover_ug Your code is giving wrong answer for “1 2 1 3”.Your code gives output as -1 but that should not be instead there exists a valid bipartite matching for that case…

I have the same problem with my code.

Can anyone please help, why my code is giving WA.

Code link :

Can it be the case that the checker function of codechef for this question is incorrect?? @admin

1 Like

@ankesh18 Both the loop runs till cnt!=m, so total number of operation will be m and hence it will not give TLE. Time complexity of @nmalviya1929 's code is O(T*m).

1 Like

I got a WA too, and I cannot figure out a case where it would fail,

Can we have this problem rejudged once cases are corrected ? @admin


it took 20 mins for knowing whether our solution for this problem was right or wrong , submitted at 9:30 and got to know the “wrong” verdict at 9:50 with 10 mins left, didn’t expect such carelessness from codechef for this contest.

your solution is wrong. u also have to take care not to assign degree more than D. i see that u haven’t taken care of that. @nmalviya

@nmalviya Try this case 100 10000 1 10

UPD-Sorry Wrong Case…

guys,most of you have made same all are printing edges and then checking the condition.
@nmalviya Try this:
1 0 0 1
your output is 1 1.but no. of edges to be printed is 0.
hope this helps.

Yes, I have the same doubt.

Rejudging solutions still doesn’t give us the time we would have got “during” the contest.

Not to mention those 10 minutes of “running” for each supposedly wrong submission.

So many faults while hosting such an important contest is simply not justified.


Did u guys handle the case when m=0 and n=0?? Even I couldn’t figure it out until the contest finished. :frowning:

According to the constraints given in the question n >= 1

My Solution