【HDOJ5977】Garden of Eden(点分治)】的更多相关文章

题目链接: 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…
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…
题目链接: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<&…
题意:给一棵节点数为n,节点种类为k的无根树,问其中有多少种不同的简单路径,可以满足路径上经过所有k种类型的点? 析:对于路径,就是两类,第一种情况,就是跨过根结点,第二种是不跨过根结点,分别讨论就好,由于结点比较大,所以采用分治来进行处理,优先选取重点作为划分的依据. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string>…
HDU - 5977 题意: 给定一颗树,问树上有多少节点对,节点对间包括了所有K种苹果. 思路: 点分治,对于每个节点记录从根节点到这个节点包含的所有情况,类似状压,因为K<=10.然后处理每个重根连着的点的值:直接枚举每个点,然后找出这个点对应的每个子集,累计和子集互补的个数. 枚举一个数的子集,例如1010,它的子集包括1010,1000,0010,0000.这里有个技巧: ) & x){ res += 1ll*cnt[((<<k)-) ^ s]; } //#pragma…
题目 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) 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…
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,…
题意:给定一棵n个点的树,每个节点上有一种颜色a[i],一共有k种颜色,问包含所有颜色的路径条数 n<=5e4,k<=10 思路:点分治求方案数 集合并卷积的时候暴力枚举状态即可O(n^logn*2^k) 75e的复杂度 只跑了1.7s 我也是醉了 #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cmath> type…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5977 题解:这题一看就知道是状压dp然后看了一下很像是点分治(有点明显)然后就是简单的点分治+状压dp,这里只要稍微改一下模版就行了.还有注意一下这里的cau状态枚举然后就没什么了 #include <iostream> #include <cstring> #include <cstdio> using namespace std; typedef long long l…