All submissions for this problem are available.
Mani has a string S and an integer d in hand. He has to deal with special strings now :( . A string is a special string if the length of its Longest Palindromic Substring is less than d. He needs to find the lexicographically smallest special string X among all special strings which are lexicographically larger than S
If there is no possible value of X, print "Impossible"(without quotes)
- First line of input contains an integer - d
- Second line contains a string S of length n
Output consists of a string in the first line, the solution to this problem
- 1 ≤ n ≤ 105
- 1 ≤ d ≤ n
|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, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.