As an input, I have a "map", which is a polygon. All its sides are parallel to x- or y-axis (so all these polygons are described by rectangles which they consist of, size of all polygons are integers). Here you can see an example of a correct and a bad input.
The second input is a set of rectangles I want to fit in. All rectangles are described by theirs sizes width*height (every rectangle could have different integer size).
For a given input, I want to find out if it is possible to put all rectangles to the map. And if so, I want to get positions of all rectangles. Moreover, I could have some more conditions on location of rectangles. For example, I know that a two rectangles A,B in a map must be connected by one side.
Is there any efficient algorithm to this problem? I would say it can be transformed to some graph problem, but I have no idea how to represent it. Thanks for any help!


2^n_slots + 2^n_rectanglesstates). - gdelab