K. Palindromization

Codeforces
IDCF10097K
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Mihahim has a string s. He wants to delete exactly one character from it so that the resulting string would be a palindrome. Determine if he can do it, and if he can, what character should be deleted. The input contains a string s of length (2 ≤ |s| ≤ 200000), consisting of lowercase Latin letters. If the solution exists, output «_YES_» (without quotes) in the first line. Then in the second line output a single integer x — the number of the character that should be removed from s so that the resulting string would be a palindrome. The characters in the string are numbered from 1. If there are several possible solutions, output any of them. If the solution doesn't exist, output «_NO_» (without quotes). ## Input The input contains a string s of length (2 ≤ |s| ≤ 200000), consisting of lowercase Latin letters. ## Output If the solution exists, output «_YES_» (without quotes) in the first line. Then in the second line output a single integer x — the number of the character that should be removed from s so that the resulting string would be a palindrome. The characters in the string are numbered from 1. If there are several possible solutions, output any of them.If the solution doesn't exist, output «_NO_» (without quotes). [samples]
**Definitions** Let $ s \in \Sigma^* $ be a string of length $ n $, where $ \Sigma = \{a, b, \dots, z\} $, and $ 2 \leq n \leq 200000 $. **Constraints** 1. $ |s| = n $ 2. $ s_i \in \Sigma $ for all $ i \in \{1, \dots, n\} $ **Objective** Determine if there exists an index $ x \in \{1, \dots, n\} $ such that the string $ s' = s_1 s_2 \dots s_{x-1} s_{x+1} \dots s_n $ is a palindrome. If such $ x $ exists, output: - First line: "YES" - Second line: $ x $ Otherwise, output: - "NO"
API Response (JSON)
{
  "problem": {
    "name": "K. Palindromization",
    "description": {
      "content": "Mihahim has a string s. He wants to delete exactly one character from it so that the resulting string would be a palindrome. Determine if he can do it, and if he can, what character should be deleted.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10097K"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Mihahim has a string s. He wants to delete exactly one character from it so that the resulting string would be a palindrome. Determine if he can do it, and if he can, what character should be deleted....",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s \\in \\Sigma^* $ be a string of length $ n $, where $ \\Sigma = \\{a, b, \\dots, z\\} $, and $ 2 \\leq n \\leq 200000 $.  \n\n**Constraints**  \n1. $ |s| = n $  \n2. $ s_i \\in \\Sigma $ f...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments