[HDU1693]Eat the Trees && 插头DP
2015-04-10 23:50
363 查看
bool x, y 打成int 搞了我好久QAQ
#include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #include<queue> #include<map> #define SF scanf #define PF printf using namespace std; typedef long long LL; const int MAXN = 12; const int MAXS = 1 << MAXN; LL d[MAXN+10][MAXN+10][MAXS+10]; int M[MAXN+10][MAXN+10], n, m, S, SS; int main() { int _T, kase = 0; SF("%d", &_T); while(_T--) { SF("%d%d", &n, &m); memset(d, 0, sizeof(d)); for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) SF("%d", &M[i][j]); d[0][m][0] = 1; for(int i = 1; i <= n; i++) { for(int s = 0; s < (1<<m); s++) d[i][0][s<<1] = d[i-1][m][s]; for(int j = 1; j <= m; j++) { for(int s = 0; s < (1<<m+1); s++) { int q = 1 << j, p = q >> 1; bool x = p & s, y = q & s; if(M[i][j]) { d[i][j][s] = d[i][j-1][s^p^q]; if(x != y) d[i][j][s] += d[i][j-1][s]; } else { if(!x && !y) d[i][j][s] = d[i][j-1][s]; else d[i][j][s] = 0; } } } } PF("Case %d: There are %lld ways to eat the trees.\n", ++kase, d [m][0]); } return 0; }
相关文章推荐
- hdu1693 Eat the Trees (插头dp)
- hdu1693 Eat the Trees 插头DP
- HDU1693_Eat the Trees_插头DP
- 【HDU1693】Eat the Trees-插头DP
- 【HDU1693】Eat the Trees(插头DP)
- hdu1693 Eat the Trees 插头DP
- [hdu1693 Eat the Trees]插头dp
- HDU 1693 Eat the Trees(插头DP)
- HDU 1693 Eat the Trees(插头DP)
- HDU - 1693 Eat the Trees(多回路插头DP)
- HDU 1693 Eat the Trees (插头dp)
- hdu 1693 Eat the Trees 插头dp入门题
- HDU 1693 Eat the Trees 插头DP
- HDU 1693 Eat the Trees 插头DP
- HDU 1693 Eat the Trees 插头DP
- hdu 1693 Eat the Trees 插头dp
- HDU 1693 Eat the Trees 插头dp
- HDU 1693 Eat the Trees(插头DP,多条回路)
- 【插头DP】Eat the trees
- hdu 1697 Eat the Trees(插头dp)