Submit | All submissions | Best solutions | Back to list |
PLD - Palindromes |
A palindrome is a word, phrase, number or other sequence of units that has the property of reading the same in either direction, e.g. 'racecar', 'solos'.
Task
You are given a number k (2≤k≤30000) and a non-empty string S whose length does not exceed 30000 lowercase letters.
We say two palindromes are different when they start from different positions. How many different palindromes of the length k does S contains?
Input
The first line contains K. The second line contains S. K does not exceed the length of S.
Output
The first and only line should consist of a single number - the number of palindromes found.
Example
Input: 5 ababab Output: 2
Added by: | Chinh Nguyen |
Date: | 2008-02-07 |
Time limit: | 0.100s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
hide comments
|
|||||
2017-12-24 07:22:01
O(n*n) accepted!!! |
|||||
2017-03-04 14:19:19
Brute force pass.. |
|||||
2017-01-05 16:43:49
brute force :) |
|||||
2016-03-11 12:12:08 minhthai
try hashing if tle |
|||||
2015-08-15 17:07:35 Anik Dasgupta
i am getting an error in the 9th case. please help! |
|||||
2015-07-25 18:06:12 Scape
Can be solved in O(N). |
|||||
2014-11-05 22:48:31 jose
which is the case 6 or 7 |
|||||
2013-05-07 15:02:39 Fahim Zubayer
Guess what? O(N log(N)^2) works! It is rather slow,though. |
|||||
2013-03-25 08:37:28 Divya Gupta
gives tle |
|||||
2013-03-17 09:34:53 Divya Gupta
time limit eceeds |