HDU 4960 Another OCD Patient pid=4960" target="_blank" style="">题目链接 记忆化搜索,因为每一个碎片值都是正数,所以每一个前缀和后缀都是递增的,就能够利用twopointer去找到每一个相等的位置,然后下一个区间相当于一个子问题,用记忆化搜索就可以,复杂度接近O(n^2) 代码: #include <cstdio> #include <cstring> #incl…
http://acm.hdu.edu.cn/showproblem.php?pid=4960 2014 Multi-University Training Contest 9 Another OCD Patient Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 181    Accepted Submission(s): 58 Pr…
Another OCD Patient Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 645    Accepted Submission(s): 238 Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) patient. This mornin…
思路: 因为是对称的,所以如果两段是对称的,那么一段的前缀和一定等于另一段的后缀和.根据这个性质,我们可以预处理出这个数列的对称点对.然后最后一个对称段是从哪里开始的,做n^2的DP就可以了. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> #inc…
Another OCD Patient Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 716    Accepted Submission(s): 270 Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) patient. This morni…
Another OCD Patient Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 490    Accepted Submission(s): 180 Problem Description    Xiaoji is an OCD (obsessive-compulsive disorder) patient. This mo…
Another OCD Patient Problem Description Xiaoji is an OCD (obsessive-compulsive disorder) patient. This morning, his children played with plasticene. They broke the plasticene into N pieces, and put them in a line. Each piece has a volume Vi. Since Xi…
题意: 给一些圆,要求从第一个圆的圆心走到最后一个圆的圆心,中间路径必须在某个圆内,求最短路径的长度. 解法: 易知要保持在圆内且路径最短,走两圆相交的点能使路径尽量短,所以我们找出所有的两圆相交的点,再加上起点和终点,放到一个容器中,去重后,判断每两点之间的线段是否都在圆内,如果是则建边,建完所有的边后跑一个SPFA即可得出最短路. 代码: #include <iostream> #include <cstdio> #include <cstring> #includ…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5637 题意: http://bestcoder.hdu.edu.cn/contests/contest_chineseproblem.php?cid=675&pid=1003 题解: 令n=(1<<17)-1. 首先很容易想到建图,跑最短路,不过有多次查询,如果每次都跑最短路的话要m*n*logn,会t. 所以可能是我们模型建的太一般化了,需要考虑题目的特殊性. s到t的最少变化次数本质…
转载请注明出处,谢谢http://blog.csdn.net/ACM_cxlove?viewmode=contents    by---cxlove 题目:给出n个城市需要去占领,有m条线段是障碍物,有p个士兵可以用.占领城市有个先后顺序,每个士兵有个背包,占领城市之后,仅能补给一次背包.问背包容量最少是多少,可以用这P个士兵完成任务,起点任意 . http://acm.hdu.edu.cn/showproblem.php?pid=4606 首先:枚举所有顶点,求一下距离,判断是否与线段相交.然…