HDU - 1693 Eat the Trees——插头dp
手推了一下,算是稍微明白了一点插头dp的原理
#include #include #include #include using namespace std;const int maxn = 15;const int maxm = 1<<15;typedef long long ll;int T, n, m, a[maxn][maxn];int pre, cur, vis[maxm], total[2], state[2][maxm];ll dp[2][maxm], ans;void init() { memset(a, 0, sizeof(a)); pre = -1, cur = 0; total[0] = 1; state[0][1] = 0; dp[0][1] = 1; ans = 0;}void addedge(int s, ll num) { if (vis[s]) { dp[cur][vis[s]] += num; } else { vis[s] = ++total[cur]; state[cur][total[cur]] = s; dp[cur][total[cur]] = num; }}void plugdp() { for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { memset(vis, 0, sizeof(vis)); pre = cur; cur ^= 1; total[cur] = 0; for (int k = 1; k <= total[pre]; k++) { int s = state[pre][k]; ll num = dp[pre][k]; int r = ((s&(1<<(j-1)))?1:0); int d = ((s&(1<
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
暂时没有评论,来抢沙发吧~