Geek Sundaram and his girlfriend
All submissions for this problem are available.
Geek Sundaram has a girlfriend with whom he likes to spend his time. Because of his anxiousness he is not able to come up with any topic to start the conversation. After a while he starts with a shuffled palindromic string. His girlfriend shuffles the same string and makes another palindrome. Again Geek finds another palindrome. This conversation goes on until they run out of palindromes in the given string. S.
Find the number of strings that occur in the conversation between them.
P.S. In order to maintain a strong relationship the conversation must last for a long time.
If there are no such strings print -1
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains a string S
- For each test case, output a single line containing the number of distinct palindromic anagrams in the given string
- 1 ≤ T ≤ 106
- 1 ≤ |S| ≤ 30
Input: 4 level baaaa hello malayalam Output: 2 1 -1 12
Example case 1. level has two possible palindromic strings - level and elvle
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions