HDU - 4455 Substrings(非原创)】的更多相关文章

题目链接:hdu 4455 Substrings 题目大意:给出n,然后是n个数a[1] ~ a[n], 然后是q次询问,每次询问给出w, 将数列a[i]分成若干个连续且元素数量为w的集合,计算每个集合中出现的数字种类,输出总和. 解题思路:一开始想到遍历的算法,保持集合元素为w,每次剔除最前一个,加入一个,移动集合,维护数字种类,这种算法的复杂度为o(n^2), 但是超时了,后来看了下题解,dp[i] = dp[i - 1] + sum[i] - cnt; http://blog.csdn.n…
XXX has an array of length n. XXX wants to know that, for a given w, what is the sum of the distinct elements' number in all substrings of length w. For example, the array is { 1 1 2 3 4 4 5 } When w = 3, there are five substrings of length 3. They a…
Substrings Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3240    Accepted Submission(s): 990 Problem Description XXX has an array of length n. XXX wants to know that, for a given w, what is t…
Substrings Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1161    Accepted Submission(s): 351 Problem Description XXX has an array of length n. XXX wants to know that, for a given w, what is…
Substrings Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1727    Accepted Submission(s): 518 Problem Description XXX has an array of length n. XXX wants to know that, for a given w, what is…
Substrings Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3269    Accepted Submission(s): 999 Problem Description XXX has an array of length n. XXX wants to know that, for a given w, what is t…
题意: 给一串数字,给q个查询,每次查询长度为w的所有子串中不同的数字个数之和为多少. 解法:先预处理出D[i]为: 每个值的左边和它相等的值的位置和它的位置的距离,如果左边没有与他相同的,设为n+8(看做无穷). 考虑已知w=k的答案,推w = k+1时,这时每个区间都将增加一个数,即后n-k个数会增加到这些区间中,容易知道,如果区间内有该数,那么个数不会加1,,即D[i] > k时,结果++,即查询后n-k个数有多少个D[i] > k 的数即为要加上的数,然后最后面还会损失一个区间,损失的…
这个……真心看不出来是个DP,我在树状数组的康庄大道上欢快的奔跑了一下午……看了题解才发现错的有多离谱. 参考:http://www.cnblogs.com/kuangbin/archive/2012/11/11/2765329.html #include <cstdio> #include <cstring> #include <cstdlib> #include <algorithm> #define LL long long int using nam…
非原创,搬运至此以作笔记, 原地址:http://www.cnitblog.com/houcy/archive/2012/11/28/86801.html 1.用top命令查看哪个进程占用CPU高gateway网关进程14094占用CPU高达891%,这个数值是进程内各个线程占用CPU的累加值.   PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND     14094 root      15   0  315m…
非原创,具体出自哪里忘了,如果侵害您的利益,请联系我. CSS样式命名整理 页面结构 容器: container/wrap 整体宽度:wrapper 页头:header 内容:content 页面主体:main 页尾:footer 导航:nav 侧栏:sidebar 栏目:column 中间内容:center 导航 导航:nav 导航:mainbav/globalnav 子导航:subnav 顶导航:topnav 边导航:sidebar 左导航:leftsidebar 右导航:rightside…