上一页 1 2 3 4 5 6 7 ··· 18 下一页
摘要: dp。 首先这棵树是一个treap。 权值我们可以改成任意实数,所以权值只表示相互之间的大小关系,可以离散化。 树的中序遍历是肯定确定的。 用f[l][r][w]表示中序遍历为l到r,根的权值必须大于w的最小代价。 当a[x].ww时,还有f[l][r][w]=min(f[l][x-1][w]+f[x+1][r][w]+s[l][r]).不用修改了。 对于[1,n]来说,根的权值只存在... 阅读全文
posted @ 2016-07-10 22:12 invoid 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 数位dp。 数位dp一直掌握的不好。 用数位dp求出含若干个1的数的个数。 #include #include #include #define LL long long using namespace std; const LL maxn = 60; const LL mod = 10000007; LL C[maxn][maxn],a[maxn]; LL n,res,cnt; ... 阅读全文
posted @ 2016-07-10 18:52 invoid 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 半平面交。 半平面指的就是一条直线的左面(也不知道对不对) 半平面交就是指很多半平面的公共部分。 这道题的解一定在各条直线的半平面交中。 而且瞭望塔只可能在各个点或者半平面交折线的拐点处。 求出半平面交,枚举即可。 #include #include #include #include #define eps 1e-7 using namespace std; const int... 阅读全文
posted @ 2016-07-09 19:27 invoid 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 玄学,位运算。 首先1到n的路径可以看作一条简单路径和套很多环。由于异或的特性直接走和绕环一次再走是有区别的。 预处理出所有的环。 然后用一种类似于gauss消元的方式使每一位尽量为1(就是每个数都只有一位为1,剩下为0)。 然后和res异或就可以了。 #include #include #include #define LL long long using namespace ... 阅读全文
posted @ 2016-07-09 10:02 invoid 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 树形dp。 本来是想做一系列树分治的,结果这道题树形dp就可以了(膜popoqqq大神) f数组保存每个节点距离为0,1,2的点对数量。 不断统计就可以辣。 #include #include #include using namespace std; const int maxn = 20000 + 10; const int maxm = 40000 + 10; stru... 阅读全文
posted @ 2016-07-09 00:19 invoid 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 树分治。 网上有部分人的题解写的啥呀。。。 按重心进行分治。 首先O(n)算出以当前点为根depth(u)+depth(v) #include #include using namespace std; const int maxn = 10000 + 10; const int maxm = 20000 + 10; const int inf = 0x3f3f3f3f; int g[max... 阅读全文
posted @ 2016-07-08 16:23 invoid 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 2-SAT。 首先有平面图定理 m #include #include using namespace std; const int maxn = 10000 + 10; const int maxm = 3000000 + 10; int g[maxn],v[maxm],next[maxm],eid; int a[maxn],b[maxn],c[maxn],pos[maxn]; bool t... 阅读全文
posted @ 2016-07-08 12:30 invoid 阅读(622) 评论(0) 推荐(0) 编辑
摘要: 2-SAT。 读入用了黄学长的快速读入,在此膜拜感谢。 把每对时间当作俩个点。如果有交叉代表相互矛盾。 然后tarjan缩点,这样就能得出当前的2-SAT问题是否有解。 如果有解,跑拓扑排序就能找出一个特定的解。 #include #include #include using namespace std; const int maxn = 5000 + 10; const int... 阅读全文
posted @ 2016-07-08 01:00 invoid 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 2-SAT。 tarjan缩点。强连通分量的点要选一起选。 #include #include #include using namespace std; const int maxn = 20000 + 10; const int maxm = 200000 + 10; int n,m; int a[maxn],b[maxn]; int g[maxn],v[maxm],next[ma... 阅读全文
posted @ 2016-07-07 20:55 invoid 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 2-SAT。 好像很复杂的样子所以还在慢慢摸索。。。 这道题只需要tarjan缩点就可以了,如果有一个材料的满式和汉式同时被选中,代表不可能实现。 #include #include #include using namespace std; const int maxn = 5000 + 10; int g[maxn],v[maxn],next[maxn],eid; int n,m,... 阅读全文
posted @ 2016-07-07 18:39 invoid 阅读(310) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 18 下一页