Ultraviolet A -- 103 Stacking Boxes + dp
Question:
In fact, it is to extend the rectangle nesting to n-dimensional, but it is stipulated that the n-dimensional ry can be distorted at will.
Ideas:
It is based on the idea of rectangular nesting, but when determining whether it can be nested, we can directly sort the order to determine (because it can be arbitrarily distorted ). There is also the need to print the entire sequence. here we can use the idea in the book to print it recursively.
The Code is as follows:
#include
#include
#include
#includeusing namespace std;int st[50][15];int map[50][50],d[50],n,m;int dp(int i){ if(d[i]>0) return d[i]; d[i]=1; for(int j=0;j
=b[i]) return 0; return 1;}void Init(){ memset(d,0,sizeof(d)); memset(map,0,sizeof(map));}int main(){ int i,j; while(scanf("%d%d",&n,&m)!=EOF) { for(i=0;i
ans) { ans=t; k=i; } } printf("%d\n",ans); print(k); printf("\n"); } return 0;}