Submit | All submissions | Best solutions | Back to list |
IITKWPCA - Niceness of the string |
The niceness of a string s (s comprises of a-z, A-Z and space characters only) is calculated using steps given below.
- First seperate out the string into continous non zero length string without space. eg. Let us take s = "now do it now". You can break this into four small strings as "now", "do", "it" and "now". Call the set of these small strings to be G.
- Now reverse all the strings in G. eg. "won", "od", "ti", "won".
- Finally you calculate number of distinct strings in you set. in this case answer is 3. as "won", "od" and "ti" are set of distinct strings. Note that "won" comes twice but counted only once.
So you have to find niceness value of a string s.
Note that given string s can contain more than one continous spaces. eg. "now do it now ". Niceness value of this is also same as above given example.
Input
T: number of test cases. (T <= 100)
for next T lines, every line contains one string s (1 <= |s| <= 104)
Output
For every test case, output niceness value of given string s.
Example
Input: 4 now do it now now do it now I am good boy am am Output: 3 3 4 1
Added by: | praveen123 |
Date: | 2013-08-05 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | IITK ACA CSE online judge |
hide comments
|
||||||||
2015-01-07 13:15:25 Aayush
Python 3.4 : "internal error" Python 2.7 AC re(vamsi): PyPy and Python 3.4 are available only in Cube cluster edit(vamsi): cluster is changed, now you can submit in Python 3.4 Last edit: 2015-02-03 16:30:26 |
||||||||
2014-11-06 19:49:36 NISHANT RAJ
take care of empty string (means only spaces) |
||||||||
2014-10-07 13:34:35 Vamsi Krishna Avula
@eightnoteight, two lines :P |
||||||||
2014-09-04 16:57:51 eightnoteight
AC in 3 lines of python |
||||||||
2014-08-18 09:17:20 `Ak
[Link Removed] i got runtime error(SIGSEGV) pls help :( re(vamsi): don't post your code/link to code here. use forum Last edit: 2015-02-03 16:29:01 |
||||||||
2014-07-28 21:23:15 SUHAS E J
Easy in c++ using stringstream... but in python, just 3 lines of code.. :P |
||||||||
2014-07-01 08:12:59 Master_Mind
@praveen123 Getting wa.don't know why .please check my submission id 11861293 |
||||||||
2014-06-04 10:33:41 John and the cows
ahhh, I get NZEC again and again and again, don't know why :/ |
||||||||
2014-06-02 20:34:25 GURVINDER SINGH
STL rocks :P |
||||||||
2014-02-19 16:25:05 Alexandre Henrique Afonso Campos
AC with one line code in python. Two to use libraries for fast IO, but I got WA. Apparently you must use the given number. To fix that, 3 lines. Last edit: 2014-02-19 16:29:06 |