Showing posts with label Partitioning. Show all posts
Showing posts with label Partitioning. Show all posts

Tuesday, March 17, 2015

UVa 10364 - Square

Problem Statement :

Solution:
This is an innocent looking problem, but actually it is a variant of set partitioning, an NP complete problem. To solve the problem, I used a bitmasking technique coupled with a dynamic programming technique to come up with an \( O(N2^N) \) solution. While I like the problem itself, to pass the time limit on UVa, you may require some optimisations to the plain DP implementation, which makes the experience a little bit unappealing to me.