What was this ?

this and this, similar to Jealous Numbers

How you solved the 4th one?

@thezodiac1994. i tried a lot, can you give link to your solution if did using linear diophantine way? My solution link: https://www.codechef.com/viewsolution/10561001

What is your approach to find the sum closest to sum/2. I tried the standard dp but got tle and couldnā€™t fix it until the end of contest. :confused:

@pranavarora - simple subset sum solution - for(i=0; i<n; i++) { for(j=MAX; j>=a[i]; jā€“) possible[j] |= possible[j-a[i]] }

If you donā€™t mind, can you please share the code?

1 Like
  1. make a set of east west moves. call sum of this set as sum1.
  2. make a set of north south moves. sum of this set = sum2.
  3. find closest sum of subsets to sum1/2 and sum2/2 in sets 1 and 2 and add them.

https://www.cs.cmu.edu/~adamchik/21-127/lectures/divisibility_5_print.pdf

Read the part on positive solutions.

my soln - https://www.codechef.com/viewsolution/10553009.

Can anyone provide solution to vCake problem? I solved all possible cases, yet it gave me ā€œWrong Answer!ā€ā€¦ not sure whyā€¦

@giorgosgiapis For COLTREE my approach. Suppose you choose i colours to use (nCr(k,i) ways), then you need to partion the tree in i different units that can be done simply by selecting any i-1 edges (nCr(n-1,i-1) ways ) and then arranging the i colors (i! ways). Sum over this from i = 1 to i =min(k,n).
I got WA once because I sumed from i = 1 to i = k, may be that would have been the case for you as well.
Thank you.

Thanks! :slight_smile:

Hereā€™s my solution for the VCake problem.link text
Would be helpful if someone posts the solution for the second one.

Can anyone give the solution for color tree ?

In the problem VCake can someone clarify what is meant by the line:
They want their pieces to be connected (in one piece), and rectangular in shape.
Does that mean that each piece should necessarily share its boundaries with other two pieces?

If thats the case then what is the problem with this solution?

Can you please upload it on ideone @thezoidac1994. They have not made solution visible yet. Edit: this was my code: http://ideone.com/DsTMC7

Please someone post the solution for color tree

Can anybody help me out with jealous number question?
I tried a lot but couldnā€™t crack the logic :frowning:

@sam5125 Your solution will fail this case: 4 5 10 5 5. You missed the case where every piece can be parallel to one side of the rectangle.

Here is my solution to 2nd problem:
Chocolate Solution

Can anybody look to my solution of VCake. It is giving me WA and I have considered every possible combination to ensure it does not miss any case. Thanks
Cake solution