@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).
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.
guys,most of you have made same mistake.you 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.
I just don’t know what people at Codechef office are happy about.
Reference: Redirecting...
There servers weren’t ready to take the load of the high submission rate but still they went for the Common Online Test. My team was logged out 9-10 times due to session limit and the submission’s were in Queue for more than 20 minutes. It’s just frustating.
@tumblehead When n=100 and m=10000,every node of bipartite graph has degree 100, which doesn’t satisfy the condition d<=deg(v)<=D (d=1 & D=10). And @nmalviya1929 's code is giving -1 answer for that, which is correct.
Approach used here is greedy and degree of n nodes is increased one by one. To increase degree of all nodes by one, we need n edges. And condition m<=((2nD)/2) is already checked.