POJ 3254 Corn Fields (squashed DP + scrolling array)
Address: POJ 3254
Pressure water problems.
Pre-process all possible situations in each row. Then we can store them with a vector.
Then, process all the conditions in the first line. Then, starting from the second line, the status will be transferred continuously with the previous line. The status transfer will be simple and will not be said.
Finally, you can calculate the sum of the number of the last row.
The Code is as follows;
#include
#include
#include
#include
#include #include
#include
#include
#include
using namespace std;#define LL __int64const int mod=100000000;const int INF=0x3f3f3f3f;int a[20][20];int dp[3][1<<13];vector
vec[13];bool Judge(int x, int y, int m){ int i; for(i=0; i
0&&(j&(1<
=mod) dp[i&1][tmp]%=mod; } } if(i==n-1) { ans+=dp[i&1][tmp]; if(ans>=mod) ans%=mod; //printf("%d\n",ans); } } } if(n==1) { ans=vec[0].size(); } printf("%d\n",ans); return 0;}