{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eFernando is president of country named Palindromia. Every two years there are elections in Palindromia, but not normal elections. Elections in Palindromia are preformed in next steps:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eCandidate which at the moment isn\u0027t president gives to the current president one string \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e, which consist only of upper-case letters of English alphabet and character \u0027?\u0027, string \u003cstrong\u003e\u003cem\u003eU\u003c/em\u003e\u003c/strong\u003e, which consist only of upper-case letters of English alphabet, and integer \u003cstrong\u003e\u003cem\u003eK\u003c/em\u003e\u003c/strong\u003e. \u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eCurrent president has one day to compute all longest palindromes in the first string by the following rules:\u003cbr\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eEvery \u0027?\u0027 in \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e is substituted with one letter from \u003cstrong\u003e\u003cem\u003eU\u003c/em\u003e\u003c/strong\u003e, \u003cstrong\u003e\u003cem\u003ei\u003c/em\u003e\u003c/strong\u003e-th \u0027?\u0027 in \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e with \u003cstrong\u003e\u003cem\u003ei\u003c/em\u003e\u003c/strong\u003e-th letter in \u003cstrong\u003e\u003cem\u003eU\u003c/em\u003e\u003c/strong\u003e.\u003c/li\u003e\r\n\u003cli\u003eEvery time he search for palindromes, he may substitute some \u0027?\u0027 with any letter, at most \u003cstrong\u003e\u003cem\u003eK\u003c/em\u003e\u003c/strong\u003e-times.\u003c/li\u003e\r\n\u003cli\u003eIf he finds palindrome, he goes to step 1.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eIf he doesn\u0027t succeed, the candidate becomes the new president.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eIf there are more candidates, go to step one.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eFernando wants to stay president for at least two more years, so he asks you to write program which solves his problem.\u003c/p\u003e\r\n\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eFirst line of input will contain string \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e (1 \u0026lt;\u003d length of \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e \u0026lt;\u003d 5 * 10^5), string which Fernando must compute to stay president. \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e will consist only of upper-case letters of English alphabet and character \u0027?\u0027. You may assume there is at least one \u0027?\u0027 in \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e.\u003c/p\u003e\r\n\u003cp\u003eSecond line will contain string \u003cstrong\u003e\u003cem\u003eU\u003c/em\u003e\u003c/strong\u003e, string with leads for \u0027?\u0027s. \u003cstrong\u003e\u003cem\u003ei\u003c/em\u003e\u003c/strong\u003e-th letter in \u003cstrong\u003e\u003cem\u003eU\u003c/em\u003e\u003c/strong\u003e correspond to \u003cstrong\u003e\u003cem\u003ei\u003c/em\u003e\u003c/strong\u003e-th \u0027?\u0027 in \u003cstrong\u003e\u003cem\u003eO\u003c/em\u003e\u003c/strong\u003e. \u003cstrong\u003e\u003cem\u003eU\u003c/em\u003e\u003c/strong\u003e will consist only of upper-case letters of English alphabet.\u003c/p\u003e\r\n\u003cp\u003eThird line will contain integer \u003cstrong\u003e\u003cem\u003eK\u003c/em\u003e\u003c/strong\u003e (0 \u0026lt;\u003d K \u0026lt;\u003d 300), number of replacements.\u003c/p\u003e\r\n\u003cp\u003e\u003cstrong\u003e\u003cem\u003e\u003cu\u003eIt is guaranteed that there will be not more than 300 \u0027?\u0027s.\u003c/u\u003e\u003c/em\u003e\u003c/strong\u003e\u003c/p\u003e\r\n\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eIn first line of output print integer \u003cstrong\u003e\u003cem\u003eS\u003c/em\u003e\u003c/strong\u003e, length of the longest palindrome that Fernando could find.\u003c/p\u003e\r\n\u003cp\u003eIn Second and next lines print string \u003cstrong\u003e\u003cem\u003eP\u003c/em\u003e\u003c/strong\u003e\u003cem\u003e\u003cstrong\u003e\u003csub\u003ei\u003c/sub\u003e\u003c/strong\u003e\u003c/em\u003e and integer \u003cstrong\u003e\u003cem\u003eL\u003csub\u003ei\u003c/sub\u003e, \u003c/em\u003e\u003c/strong\u003elongest palindrome and position where it starts. Each \u003cstrong\u003e\u003cem\u003eP\u003c/em\u003e\u003c/strong\u003e\u003cem\u003e\u003cstrong\u003e\u003csub\u003ei\u003c/sub\u003e\u003c/strong\u003e\u003c/em\u003e must contain only upper-case letters of English alphabet.\u003c/p\u003e\r\n\r\n\u003ch4\u003eNotes:\u003c/h4\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eyou must print all longest palindromes, in alphabetically increasing order\u003c/li\u003e\r\n\u003cli\u003eif two or more palindromes starts at the same position, print only one of them\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eUDOVICAB??IVODUANAVOL?MILOVANA\r\nCCA\r\n1\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e15\r\nANAVOLIMILOVANA 16\r\nUDOVICABACIVODU 1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003cp\u003eNote that both palindromes have 1 letter which Fernando has changed.\u003c/p\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eABCDE??ABCDE??\r\nABCD\r\n1\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\nCBABC 6\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eABCDE??ABCDEFG\r\nFG\r\n0\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\nA 1\r\nA 8\r\nB 2\r\nB 9\r\nC 10\r\nC 3\r\nD 4\r\nD 11\r\nE 5\r\nE 12\r\nF 13\r\nF 6\r\nG 7\r\nG 14\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\n\u003c/div\u003e"}}]}