题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5785 Description Alice get a string S. She thinks palindrome string is interesting. Now she wanna know how many three tuple (i,j,k) satisfy 1≤i≤j<k≤length(S), S[i..j] and S[j+1..k] are all palindrom…
题目大意:给一个字符串,求所有相邻两回文子串的外侧下标之积的和 题目分析:另L[i]为所有以 i 为右端点的回文字串的左端点之和,同理,另R[i]表示所有以 i 为左端点的回文子串的右端点之和.显然,答案为sigma(L[i]*R[i+1]) 其中,1<=i<length(字符串).求出L和R是关键.先用manacher算法处理出p数组,然后再求出L和R.求L和R的思想(非常巧妙)跟树状数组求区间和的思想差不多.不过,这道题如果用树状数组或线段树的话会超时. 参考代码: # include&l…
EBCDIC Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 102400/102400 K (Java/Others)Total Submission(s): 160 Accepted Submission(s): 81 Problem Description A mad scientist found an ancient message from an obsolete IBN System/360 mainframe.…
H - Solve this interesting problem Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 5323 Appoint description: System Crawler (2015-07-28) Description Have you learned something about segment tr…
用manacher算法O(n)求出所有的回文半径.有了回文半径后,就可以求出L[i]表示以i结尾的回文串的起始位置的和R[i]表示以i起始的回文串的结尾位置的和,然后就可以求出答案了,这里要注意奇偶长度回文串的不同处理.复杂度O(n) #include<bits/stdc++.h> using namespace std; ; typedef long long ll; ; ]; ]; ll L[N], R[N]; void add(ll& a, ll b){ a += b; if(a…
Hotaru's problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 2274 Accepted Submission(s): 795 Problem Description Hotaru Ichijou recently is addicated to math problems. Now she is playin…
Rikka with Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Problem Description Though both Rikka and Yuta are busy with study, on their common leisure, th…
题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly. But as the saying goes:…
题目链接 Problem Description RXD has a tree T, with the size of n. Each edge has a cost. Define f(S) as the the cost of the minimal Steiner Tree of the set S on tree T. he wants to divide 2,3,4,5,6,-n into k parts S1,S2,S3,-Sk, where ⋃Si={2,3,-,n} and fo…
Little W and Contest Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0 Problem Description There are n members in our ACM club. Little W wants to select three pers…