What Is This LOL!
All submissions for this problem are available.
While in ISM, you spend most of your time in chatting, either on facebook, gtalk or through sms. You noticed that lots of your friends write "lol", whenever you tell them a joke. You noticed that lol is a special word as it is equal to itself when reversed. You found out that such words are called palindrome. Now you see some words that are not palindromes but after certain operations(swapping) those words may or may not be transformed in palindromes. You try to find out the minimum number of steps performed for this transformation. You can only swap two adjacent letters at a time. You have to find out the minimum number of swapping required to perform the operation
The first line of input will be an integer T , the number of test cases. For each test case, there will be a separate line entry containing a string up to 80 lowercase letters
For each test case there will be one line output. This line will print the minimum number of swaps, or "Not Possible" if it is not possible to transform the input to a palindrome
Input: 4 ffi aktktinan dhanbad wcgyecvfggqrwrvfyeg Output: 1 9 Not Possilbe 24
|Time Limit:||2 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.5, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.