Time Limit: 1s
Memory Limit: 512MB
There is a container having horizontal size W and vertical size H. There are N rectangle items 1, 2, ..., N in which item i has horizontal size wi and vertical size hi. Find the way to place these N items into the container such that:
The input consists of following lines:
Line 1: contains two integer H and W (1≤ H,W≤ 30)
Line 2: contains N (1≤ N≤ 12)
Line i+2 (i=1,2,...,N): contains two integers hi and wi
The output contains a unique number 0 (if we cannot place items) or 1 (if we can place items).
6 4 3 2 3 6 1 4 3
1