Won't we be able to choose from (n+m-2*k)C(n-k)? As the number of choices are n-k down and m-k right, and we have to choose n-k options. Also, min(m,n)C(k) are the number of choices for diagonals for each k.
Need help! My solution fails for the some of the testcases in the second subtask(d=2).
No. The insertion first checks if the element is lesser than or greater than the root at each level. In short, if its in left sub-tree, it must have been smaller than the root. Irrespective of whether it ends up in left or right sub-tree.