hdu5977 Garden of Eden】的更多相关文章

题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5977 Description When God made the first man, he put him on a beautiful garden, the Garden of Eden. Here Adam lived with all animals. God gave Adam eternal life. But Adam was lonely in the garden, s…
题目链接: Garden of Eden Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 210    Accepted Submission(s): 75 Problem Description When God made the first man, he put him on a beautiful garden, the G…
HDU - 5977 题意: 给定一颗树,问树上有多少节点对,节点对间包括了所有K种苹果. 思路: 点分治,对于每个节点记录从根节点到这个节点包含的所有情况,类似状压,因为K<=10.然后处理每个重根连着的点的值:直接枚举每个点,然后找出这个点对应的每个子集,累计和子集互补的个数. 枚举一个数的子集,例如1010,它的子集包括1010,1000,0010,0000.这里有个技巧: ) & x){ res += 1ll*cnt[((<<k)-) ^ s]; } //#pragma…
都不好意思写题解了 跑了4000多ms 纪念下自己A的第二题 (我还有一道freetour II wa20多发没A...呜呜呜 #include<bits/stdc++.h> using namespace std; #define sz(X) ((int)X.size()) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define index Index typedef long long ll; const…
题目大意:求有所有颜色的路径数. 题目分析:参考codeforces997C,先利用基的FMT的性质在$O(2^k)$做FMT,再利用只还原一位的特点在$O(2^k)$还原,不知道为什么网上都要点分治. 代码: #include<bits/stdc++.h> #define R register using namespace std; ; int n,k,a[maxn],fa[maxn],cnt[maxn],head[maxn]; struct edge{int to,nxt;}edges[…
Cellular automata are mathematical idealizations of physical systems in which both space and time are discrete, and the physical quantities take on a nite set of discrete values. A cellular automaton consists of a lattice (or array), usually in nite,…
Problem Description When God made the first man, he put him on a beautiful garden, the Garden of Eden. Here Adam lived with all animals. God gave Adam eternal life. But Adam was lonely in the garden, so God made Eve. When Adam was asleep one night, G…
Garden of Eden Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Problem Description When God made the first man, he put him on a beautiful garden, the Garden of Eden. Here Adam lived with all animals. God gave Ad…
题目链接:https://vjudge.net/problem/HDU-5977 题意:给一颗树,每个结点上有一个权值a[i],a[i]<=10,求有多少条路径满足这条路径上所有权值的结点都出现了. 思路: 首先利用二进制的思想,将a[i]转化为1<<(a[i]-1).我们在子树中,计算出结点到重心的路径,用二进制表示,比如011表示该路径中权值3没有出现.权值1和2出现.因为k最大为10,那么我们在计算结果时把所有可能枚举一遍,也就1024,如果枚举的i和当前路径取或后=(1<&…
题解: 路径统计比较容易想到点分治和dp dp的话是f[i][j]表示以i为根,取了i,颜色数状态为j的方案数 但是转移这里如果暴力转移就是$(2^k)^2$了 于是用FWT优化集合或 另外http://www.cnblogs.com/sclbgw7/p/9508235.html给出了一种技巧优化空间 就是我们优先处理重儿子,这样子我们上面记录的状态一定都是连着轻边的 而由树链剖分的复杂度证明我们可以知道一条路径上轻边最多只有log条 为什么呢,因为重儿子肯定比轻儿子大,所以至少翻倍…