博客园 - <Dash>
uuid:24b78886-0ed1-41c2-8670-e3f31dcf42c4;id=79963
2015-08-18T05:21:16Z
<Dash>
https://www.cnblogs.com/dashgua/
feed.cnblogs.com
https://www.cnblogs.com/dashgua/p/4722941.html
NTT 分类: templates 2015-08-11 23:34 3人阅读 评论(0) 收藏 - <Dash>
我觉得我还需要理解一下 FFT 和 NTT …#include #include #include #include const int maxn = 4e4+5, Mod = 950009857;const int G = 7;int n, m, k, N = 1;long lon...
2015-08-11T15:34:00Z
2015-08-11T15:34:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】我觉得我还需要理解一下 FFT 和 NTT …#include #include #include #include const int maxn = 4e4+5, Mod = 950009857;const int G = 7;int n, m, k, N = 1;long lon... <a href="https://www.cnblogs.com/dashgua/p/4722941.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722942.html
ToDoList 分类: introspect 2015-08-11 23:30 3人阅读 评论(0) 收藏 - <Dash>
poj2376bzoj3110 版权声明:本文为博主原创文章,未经博主允许不得转载。
2015-08-11T15:30:00Z
2015-08-11T15:30:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】poj2376bzoj3110 版权声明:本文为博主原创文章,未经博主允许不得转载。 <a href="https://www.cnblogs.com/dashgua/p/4722942.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722943.html
zoj 2334 分类: zoj templates 2015-08-11 23:12 2人阅读 评论(0) 收藏 - <Dash>
可并堆,左偏树,这是神犇“顺手学的东西”以下是左偏树的合并操作代码。int merge(int x,int y){//p[i] 结点i的权值,这里是维护大根堆//d[i] 在i的子树中,i到叶子结点的最远距离. if(!x) return y; if(!y) return...
2015-08-11T15:12:00Z
2015-08-11T15:12:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】可并堆,左偏树,这是神犇“顺手学的东西”以下是左偏树的合并操作代码。int merge(int x,int y){//p[i] 结点i的权值,这里是维护大根堆//d[i] 在i的子树中,i到叶子结点的最远距离. if(!x) return y; if(!y) return... <a href="https://www.cnblogs.com/dashgua/p/4722943.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722944.html
hdu 5357 2015-08-10 22:52 7人阅读 评论(0) 收藏 - <Dash>
括号匹配,栈开始感觉题意很奇怪,表示这道题不会做。。。然而看了题解,原来并不是太难啊~!我太弱了,还是直接贴代码吧。。。#include #include #include #include #include #include #include #include #include #...
2015-08-10T14:52:00Z
2015-08-10T14:52:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】括号匹配,栈开始感觉题意很奇怪,表示这道题不会做。。。然而看了题解,原来并不是太难啊~!我太弱了,还是直接贴代码吧。。。#include #include #include #include #include #include #include #include #include #... <a href="https://www.cnblogs.com/dashgua/p/4722944.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722945.html
poj 2796 分类: poj 2015-08-10 15:38 8人阅读 评论(0) 收藏 - <Dash>
如果确定了 ax 为最小值,那么包含 ax 并且以 ax 为最小值的区间个数是 O(N2) 的。因为序列中所有数的值非负,所以只需要考虑满足以上条件的最长区间即可。而包含 ax 并且以 ax 为最小值的最长区间可以用两次单调队列求出,最后对每个 ax 计算答案即可。#include ...
2015-08-10T07:38:00Z
2015-08-10T07:38:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】如果确定了 ax 为最小值,那么包含 ax 并且以 ax 为最小值的区间个数是 O(N2) 的。因为序列中所有数的值非负,所以只需要考虑满足以上条件的最长区间即可。而包含 ax 并且以 ax 为最小值的最长区间可以用两次单调队列求出,最后对每个 ax 计算答案即可。#include ... <a href="https://www.cnblogs.com/dashgua/p/4722945.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722946.html
poj 1821 分类: poj 2015-08-10 15:37 5人阅读 评论(0) 收藏 - <Dash>
把转移方程优化一下,改变决策顺序就行了。。。#include #include #include #include #include #include #include #include #include #include #include #include #include tem...
2015-08-10T07:37:00Z
2015-08-10T07:37:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】把转移方程优化一下,改变决策顺序就行了。。。#include #include #include #include #include #include #include #include #include #include #include #include #include tem... <a href="https://www.cnblogs.com/dashgua/p/4722946.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722947.html
codeforces 366D 分类: codeforces 2015-08-09 17:38 9人阅读 评论(0) 收藏 - <Dash>
很有趣的题啊,首先要知道从 1 开始,只走一条路径到达 n 的数字一定是连续的区间,先枚举确定答案 L,再通过拓扑排序 DP 计算最大的 R (DP过程中确定无向边的方向),当然我直接写了一个 SPFA 来更新 DP 值,然后就 AC 了~SPFA期望复杂度 : O(n+m)时间复杂...
2015-08-09T09:38:00Z
2015-08-09T09:38:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】很有趣的题啊,首先要知道从 1 开始,只走一条路径到达 n 的数字一定是连续的区间,先枚举确定答案 L,再通过拓扑排序 DP 计算最大的 R (DP过程中确定无向边的方向),当然我直接写了一个 SPFA 来更新 DP 值,然后就 AC 了~SPFA期望复杂度 : O(n+m)时间复杂... <a href="https://www.cnblogs.com/dashgua/p/4722947.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722948.html
hdu 3593 分类: hdu 2015-08-09 16:43 12人阅读 评论(0) 收藏 - <Dash>
终于理解树形依赖背包啦~这个树形DP的转移方程还是比较简单的。树形依赖背包的优化:设当前结点为 x,因为选取物品 x 需要强制选取物品 fa(x),所以直接令 dp(x)=dp(fa(x)) 并限制背包空间,然后处理 dp(son(x)),最后强制加入物品 x,即用 dp(x)+g(...
2015-08-09T08:43:00Z
2015-08-09T08:43:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】终于理解树形依赖背包啦~这个树形DP的转移方程还是比较简单的。树形依赖背包的优化:设当前结点为 x,因为选取物品 x 需要强制选取物品 fa(x),所以直接令 dp(x)=dp(fa(x)) 并限制背包空间,然后处理 dp(son(x)),最后强制加入物品 x,即用 dp(x)+g(... <a href="https://www.cnblogs.com/dashgua/p/4722948.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722949.html
poj 3134 分类: poj 2015-08-08 23:42 4人阅读 评论(0) 收藏 - <Dash>
喜闻乐见的迭代加深搜索快速幂最多只需要 2∗logX 次就能得到想要的任何数然而这道题的答案会更小,迭代加深搜索显然是可以承受的。剪枝优化: 如果剩余的操作次数都用来将最大数与最大数相乘, 得到的结果仍然比希望得到的数小,那么这个状态就一定是不可行的#include #include...
2015-08-08T15:42:00Z
2015-08-08T15:42:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】喜闻乐见的迭代加深搜索快速幂最多只需要 2∗logX 次就能得到想要的任何数然而这道题的答案会更小,迭代加深搜索显然是可以承受的。剪枝优化: 如果剩余的操作次数都用来将最大数与最大数相乘, 得到的结果仍然比希望得到的数小,那么这个状态就一定是不可行的#include #include... <a href="https://www.cnblogs.com/dashgua/p/4722949.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722950.html
poj 1186 分类: poj 2015-08-08 22:28 4人阅读 评论(0) 收藏 - <Dash>
似乎是NOI 2001的题目,感觉很有意思。。。Meet in the Middle (中途相遇法)看起来O(MN)不可做,方程移项有真相:k1∗xp11+k2∗xp22+k3∗xp33=−(k4∗xp44+k5∗xp55+k6∗xp66)分别计算 :k1∗xp11+k2∗xp22+...
2015-08-08T14:28:00Z
2015-08-08T14:28:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】似乎是NOI 2001的题目,感觉很有意思。。。Meet in the Middle (中途相遇法)看起来O(MN)不可做,方程移项有真相:k1∗xp11+k2∗xp22+k3∗xp33=−(k4∗xp44+k5∗xp55+k6∗xp66)分别计算 :k1∗xp11+k2∗xp22+... <a href="https://www.cnblogs.com/dashgua/p/4722950.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722951.html
poj 1379 分类: poj templates 2015-08-08 22:17 3人阅读 评论(0) 收藏 - <Dash>
传说正解是V图,想想都觉得难写。。。模拟退火~ 随机取几个点,将温度设置为随机范围,然后随机爬山算法即可。。。如果参数设置得比较优,就可以在精度范围内取得最优解。。。所以暂时就不学V图了(反正写不出)注意如果用G++交题的话,要用 %f 输出。。。我以后还是用C++交题吧,虽然语法比...
2015-08-08T14:17:00Z
2015-08-08T14:17:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】传说正解是V图,想想都觉得难写。。。模拟退火~ 随机取几个点,将温度设置为随机范围,然后随机爬山算法即可。。。如果参数设置得比较优,就可以在精度范围内取得最优解。。。所以暂时就不学V图了(反正写不出)注意如果用G++交题的话,要用 %f 输出。。。我以后还是用C++交题吧,虽然语法比... <a href="https://www.cnblogs.com/dashgua/p/4722951.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722952.html
poj 1568 分类: poj templates 2015-08-08 16:09 6人阅读 评论(0) 收藏 - <Dash>
博弈搜索,Alpha−Beta 剪枝Alpha−Beta 剪枝:令 alpha = max{beta = min{alpha′}}如果在搜索的过程中,beta=beta,那么alpha′ 对 beta的值将没有贡献,对 alpha′ 不必继续搜索。本题还有特殊的特判技巧,然而并不会证...
2015-08-08T08:09:00Z
2015-08-08T08:09:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】博弈搜索,Alpha−Beta 剪枝Alpha−Beta 剪枝:令 alpha = max{beta = min{alpha′}}如果在搜索的过程中,beta=beta,那么alpha′ 对 beta的值将没有贡献,对 alpha′ 不必继续搜索。本题还有特殊的特判技巧,然而并不会证... <a href="https://www.cnblogs.com/dashgua/p/4722952.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722953.html
codeforces 558C 分类: codeforces 2015-08-08 14:15 9人阅读 评论(0) 收藏 - <Dash>
将每个数转成二进制的形式,可以发现对每个数的操作只会使二进制数中的 ‘1’减少,而有效的目标状态一定不大于 max{a[i]}, 所以每个数能扩展出的有效状态只有 2*log max{a[i]} 种,而这个范围是非常小的。。。可以用搜索处理出每个数能扩展出的有效状态以其代价。最后枚举...
2015-08-08T06:15:00Z
2015-08-08T06:15:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】将每个数转成二进制的形式,可以发现对每个数的操作只会使二进制数中的 ‘1’减少,而有效的目标状态一定不大于 max{a[i]}, 所以每个数能扩展出的有效状态只有 2*log max{a[i]} 种,而这个范围是非常小的。。。可以用搜索处理出每个数能扩展出的有效状态以其代价。最后枚举... <a href="https://www.cnblogs.com/dashgua/p/4722953.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722954.html
template 分类: templates 2015-08-08 13:55 7人阅读 评论(0) 收藏 - <Dash>
#include #include #include #include #include #include #include #include #include #include #include #include #include templatevoid read(Num &x)...
2015-08-08T05:55:00Z
2015-08-08T05:55:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】#include #include #include #include #include #include #include #include #include #include #include #include #include templatevoid read(Num &x)... <a href="https://www.cnblogs.com/dashgua/p/4722954.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722955.html
codeforces Round 314 div.2 分类: codeforces introspect 2015-08-08 13:52 7人阅读 评论(0) 收藏 - <Dash>
这次比赛是用小号打的,于是现在小号比大号rating高。。。QwQA题和B题很简单不多说。C题:统计子序列中长度为3,公比为 k 的等比序列的个数。从后往前处理,分别统计满足条件长度为1,2,3的序列的个数, f(i,j)=∑f(i−1,t)|t=j∗k,实现时离散化一下就好~然而,...
2015-08-08T05:52:00Z
2015-08-08T05:52:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】这次比赛是用小号打的,于是现在小号比大号rating高。。。QwQA题和B题很简单不多说。C题:统计子序列中长度为3,公比为 k 的等比序列的个数。从后往前处理,分别统计满足条件长度为1,2,3的序列的个数, f(i,j)=∑f(i−1,t)|t=j∗k,实现时离散化一下就好~然而,... <a href="https://www.cnblogs.com/dashgua/p/4722955.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722956.html
bzoj 1999 分类: bzoj noip 2015-08-07 23:37 15人阅读 评论(0) 收藏 - <Dash>
树网的核 加强版,好题~可以证明,如果存在多条直径,选取任意一条直径都是等价的。证明:如图,考虑两条直径 AB, CD,其中它们的重合部分为 EF A B \ / ...
2015-08-07T15:37:00Z
2015-08-07T15:37:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】树网的核 加强版,好题~可以证明,如果存在多条直径,选取任意一条直径都是等价的。证明:如图,考虑两条直径 AB, CD,其中它们的重合部分为 EF A B \ / ... <a href="https://www.cnblogs.com/dashgua/p/4722956.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722957.html
bzoj 2821 分类: bzoj 2015-08-07 18:38 11人阅读 评论(0) 收藏 - <Dash>
因为强制在线,所以无法用莫队算法。。。将序列分块,设块的大小为 X。首先预处理出第 i 块到第 j 块的答案,复杂度O(N2X)。然后对于每个询问,我们对整块以外的数重新计算对答案的贡献即可。 时间复杂度 O(NX∗logN)根据基本不等式,每块的大小为 N/logN−−−−−−−√...
2015-08-07T10:38:00Z
2015-08-07T10:38:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】因为强制在线,所以无法用莫队算法。。。将序列分块,设块的大小为 X。首先预处理出第 i 块到第 j 块的答案,复杂度O(N2X)。然后对于每个询问,我们对整块以外的数重新计算对答案的贡献即可。 时间复杂度 O(NX∗logN)根据基本不等式,每块的大小为 N/logN−−−−−−−√... <a href="https://www.cnblogs.com/dashgua/p/4722957.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722958.html
bzoj 2743 分类: bzoj 2015-08-07 18:22 9人阅读 评论(0) 收藏 - <Dash>
这道题的方法虽然应用不广,但很有意思。主要是维护起始点固定时,每个结束点的答案每个点记录下一个与它颜色相同的点的位置,记为next[]。首先对于所有首次出现的点 x,将 next[x] ~ n 的答案都增加 1 然后就得到了当起始点为1时,每个结束点的答案。如果起始点pos向右移动,...
2015-08-07T10:22:00Z
2015-08-07T10:22:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】这道题的方法虽然应用不广,但很有意思。主要是维护起始点固定时,每个结束点的答案每个点记录下一个与它颜色相同的点的位置,记为next[]。首先对于所有首次出现的点 x,将 next[x] ~ n 的答案都增加 1 然后就得到了当起始点为1时,每个结束点的答案。如果起始点pos向右移动,... <a href="https://www.cnblogs.com/dashgua/p/4722958.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722959.html
hdu 5068 分类: hdu 2015-08-07 18:07 7人阅读 评论(0) 收藏 - <Dash>
一道好题~用矩阵代替DP方程。对于每个房间构造一个矩阵mat,mat[i][j] = 1 或 0 表示 i 到 j 是否能到达。 然后线段树每个结点维护区间区间矩阵乘法的结果对于询问操作用矩阵乘法合并区间即可。#include #include #include #include #...
2015-08-07T10:07:00Z
2015-08-07T10:07:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】一道好题~用矩阵代替DP方程。对于每个房间构造一个矩阵mat,mat[i][j] = 1 或 0 表示 i 到 j 是否能到达。 然后线段树每个结点维护区间区间矩阵乘法的结果对于询问操作用矩阵乘法合并区间即可。#include #include #include #include #... <a href="https://www.cnblogs.com/dashgua/p/4722959.html" target="_blank">阅读全文</a>
https://www.cnblogs.com/dashgua/p/4722960.html
bzoj 3211 分类: bzoj 2015-08-07 18:00 8人阅读 评论(0) 收藏 - <Dash>
分析一下,每个数最多只会做5次开根操作就会小于或等于1,在这之后它的值就不会改变。。。用线段树记录区间的最大值,然后只对max > 1 的区间做开根操作即可。时间复杂度:O(M∗logN+N)#include #include #include #include #include #...
2015-08-07T10:00:00Z
2015-08-07T10:00:00Z
<Dash>
https://www.cnblogs.com/dashgua/
【摘要】分析一下,每个数最多只会做5次开根操作就会小于或等于1,在这之后它的值就不会改变。。。用线段树记录区间的最大值,然后只对max > 1 的区间做开根操作即可。时间复杂度:O(M∗logN+N)#include #include #include #include #include #... <a href="https://www.cnblogs.com/dashgua/p/4722960.html" target="_blank">阅读全文</a>