{"problem":{"name":"I. Mirrored String II","description":{"content":"Note: this is a harder version of Mirrored string I. The gorillas have recently discovered that the image on the surface of the water is actually a reflection of themselves. So, the next thing for th","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10135I"},"statements":[{"statement_type":"Markdown","content":"Note: this is a harder version of Mirrored string I.\n\nThe gorillas have recently discovered that the image on the surface of the water is actually a reflection of themselves. So, the next thing for them to discover is mirrored strings.\n\nA mirrored string is a palindrome string that will not change if you view it on a mirror. \n\nExamples of mirrored strings are \"MOM\", \"IOI\" or \"HUH\". Therefore, mirrored strings must contain only mirrored letters {A, H, I, M, O, T, U, V, W, X, Y} and be a palindrome.\n\ne.g. IWWI, MHHM are mirrored strings, while IWIW, TFC are not.\n\nA palindrome is a string that is read the same forwards and backwards.\n\nGiven a string S of length N, help the gorillas by printing the length of the longest mirrored substring that can be made from string S.\n\nA substring is a (possibly empty) string of characters that is contained in another string S. e.g. \"Hell\" is a substring of \"Hello\".\n\nThe first line of input is T – the number of test cases.\n\nEach test case contains a non-empty string S of maximum length 1000. The string contains only uppercase English letters.\n\nFor each test case, output on a line a single integer - the length of the longest mirrored substring that can be made from string S.\n\n## Input\n\nThe first line of input is T – the number of test cases.Each test case contains a non-empty string S of maximum length 1000. The string contains only uppercase English letters.\n\n## Output\n\nFor each test case, output on a line a single integer - the length of the longest mirrored substring that can be made from string S.\n\n[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nLet $ \\mathcal{M} = \\{A, H, I, M, O, T, U, V, W, X, Y\\} $ be the set of mirrored characters.  \nFor each test case, let $ S $ be a string of length $ N $, where $ S \\in \\Sigma^* $ and $ \\Sigma = \\{A, B, \\dots, Z\\} $.\n\n**Constraints**  \n1. $ 1 \\le T \\le \\text{unknown (implied by input)} $  \n2. For each string $ S $:  \n   - $ 1 \\le |S| \\le 1000 $  \n   - $ S $ contains only uppercase English letters.  \n\n**Objective**  \nFor each string $ S $, find the maximum length $ L $ such that there exists a substring $ S[i:j] $ (with $ 1 \\le i \\le j \\le |S| $) satisfying:  \n1. $ S[i:j] $ is a palindrome: $ S[i+k] = S[j-k] $ for all $ k = 0, 1, \\dots, \\left\\lfloor \\frac{j-i}{2} \\right\\rfloor $,  \n2. Every character in $ S[i:j] $ belongs to $ \\mathcal{M} $.  \n\nOutput $ L = \\max \\{ |S[i:j]| \\mid S[i:j] \\text{ is a mirrored substring} \\} $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10135I","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}