You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also are q queries, each query is described by two integers li, ri (1 ≤ li ≤ ri ≤ |s|). The answer to the query is the number of substrings of string s…
首先马拉车一遍(或者用hash),再做个前缀和处理出f[i][j]表示以j为右端点,左端点在[i,j]的回文串个数 然后设ans[i][j]是[i,j]之间的回文串个数,那就有ans[i][j]=ans[i][j-1]+f[i][j] #include<bits/stdc++.h> #define pa pair<int,int> #define CLR(a,x) memset(a,x,sizeof(a)) using namespace std; typedef long lon…
Queries for Number of Palindromes time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also ar…
Queries for Number of Palindromes Problem's Link: http://codeforces.com/problemset/problem/245/H Mean: 给你一个字符串,然后q个询问:从i到j这段字符串中存在多少个回文串. analyse: dp[i][j]表示i~j这段的回文串数. 首先判断i~j是否为回文,是则dp[i][j]=1,否则dp[i][j]=0; 那么dp[i][j]=dp[i][j]+dp[i][j-1]+dp[i+1[j…
H. Queries for Number of Palindromes time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also…
H. Queries for Number of Palindromes time limit per test 5 seconds memory limit per test 256 megabytes input standard input output standard output You've got a string s = s1s2... s|s| of length |s|, consisting of lowercase English letters. There also…