[Usaco06nov] Cornfield corn fields (pressure $dp$)

Source: Internet
Author: User

Topic links


Solution

Pressure (dp\) .
\ (f[i][j][k]\) represents the front \ (i\) column, has placed \ (j\) block turf, and the last state is \ (k\) .
At the same time, you can record the location in each column that cannot be placed \ (w[i]\).
Then you can easily transfer ...
The transfer equation looks at the code.

Code
#include <bits/stdc++.h> #define LL long longusing namespace Std;ll f[13][145][10000],n,k;ll Js[10000],m,sum,ans,    W[14];int Main () {cin>>n>>m;        Sum= (1<<m)-1;         for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) {int x; cin>>x;         K+=x;    w[i]=w[i]*2+x^1;        } for (ll i=0;i<=sum;i++) for (ll j=0;j<m;j++) if (i& (1<<j)) js[i]++;        for (ll i=0;i<=sum;i++) {if ((i<<1&i)) continue;        if ((i&w[1))) continue;    F[1][js[i]][i]=1;        } for (LL-i=1;i<n;i++) for (LL-j=0;j<=k;j++) for (ll k=0;k<=sum;k++) {if (!f[i][j][k]) continue;            for (ll kk=0;kk<=sum;kk++) {if (kk&w[i+1]) continue; if ((K&AMP;KK) | | | (KK&LT;&LT;1&AMP;KK))            Continue            if (j+js[kk]>k) continue;        F[I+1][J+JS[KK]][KK]+=F[I][J][K];    }} for (int. j=0;j<=k;j++) for (ll i=0;i<=sum;i++) ans+=f[n][j][i]; Cout<<anS%100000000<<endl;} 

[Usaco06nov] Cornfield corn fields (pressure $dp$)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.