Let the light guide us Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 677    Accepted Submission(s): 226 Problem Description Plain of despair was once an ancient battlefield where those brave…
题目链接 and 题目大意 hdu3698 但是 hdu的数据比较弱,所以在这luogu提交吧UVA1490 Let the light guide us 有一个\(n*m\)的平原,要求每行选一个点,选\(n\)个点建造塔楼. 平原上每个点都有他自己的花费时间和魔法值. 为了正确控制塔楼,我们必须保证连续两排的每两座塔共用一个共同的魔法区域. 也就是要求每两行相邻的点都满足如下关系: 如果第\(i\)行选\(j\),第\(i+1\)行选\(k\),则需\(|j-k|≤f(i,j)+f(i+1,…
http://acm.hdu.edu.cn/showproblem.php?pid=3698 Let the light guide us Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 759    Accepted Submission(s): 253 Problem Description Plain of despair was…
Description Plain of despair was once an ancient battlefield where those brave spirits had rested in peace for thousands of years. Actually no one dare step into this sacred land until the rumor that “there is a huge gold mine underneath the plain” s…
Let the light guide us Time Limit: 2000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 369864-bit integer IO format: %I64d      Java class name: Main   Plain of despair was once an ancient battlefield where those brave spiri…
我们预处理出来以i为结尾的最长回文后缀(回文自动机的构建过程中就可以求出)然后就是一个区间覆盖,因为我懒得写贪心,就写了线段树优化的DP. #include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; const int N=101010; const int INF=1e9; int L…
http://acm.hdu.edu.cn/showproblem.php?pid=3698 Let the light guide us Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 62768/32768 K (Java/Others) Total Submission(s): 821    Accepted Submission(s): 285 Problem Description Plain of despair was…
参考:http://blog.csdn.net/no__stop/article/details/12287843 此题利用了ac自动机fail树的性质,fail指针建立为树,表示父节点是孩子节点的后缀 然后更新其影响的字符串的方法,即区间更新,维护最大值,用线段树优化. 而其可以影响的字符串为其在fail树中的子树节点 此题一直MLE,调了一下午+晚上.最后发现. (1)ac自动机中的节点开始直接初始化,应动态初始化(也终于理解了许多人那么做) (2)还有用vector表示树边时,一开始初始c…
Hdu6606 Distribution of books 题意 把一段连续的数字分成k段,不能有空段且段和段之间不能有间隔,但是可以舍去一部分后缀数字,求\(min(max((\sum ai ))\)其中\(\sum ai\)为一段的数字和 分析 最小化最大值问题通常我们要想到二分,所以答案的求法我们就解决了,但是二分我们怎么check呢?这个时候一点思路都没有,我们考虑暴力的算法,设dp[i]表示从1--i最多可以分成多少段,怎么转移,什么情况下可以转移呢? 显然\(dp[i]=max(dp…
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=5877  题意:给你一颗树,有n个节点,每个节点都有一个权值v[i]:现在求有多少对(u,v)满足u是v的祖先,并且au*av<=k, k是已知的: 思路:从根节点开始dfs遍历整棵树,当遍历到某点u时,已经在栈中的节点都是u的祖先的,所以我们只要找到在栈中的节点有多少个是<=k/a[u]的即可: 由于n的值最大可达到10e5,所以直接查找是会TLE的,我们可以用线段树优化即可:在dfs…