E. Substring Reverse

Codeforces
IDCF10175E
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Two strings s and t of the same length are given. Determine whether it is possible to make t from s using exactly one reverse of some its substring. The first line contains the string s, and the second — the string t. Both strings have the same length from 1 to 200000 characters and consist of lowercase Latin letters. Output «_YES_», if it is possible to reverse some substring of s to make s equal to t, and «_NO_», otherwise. ## Input The first line contains the string s, and the second — the string t. Both strings have the same length from 1 to 200000 characters and consist of lowercase Latin letters. ## Output Output «_YES_», if it is possible to reverse some substring of s to make s equal to t, and «_NO_», otherwise. [samples]
**Definitions** Let $ s, t \in \Sigma^n $ be two strings of equal length $ n $, where $ \Sigma $ is the set of lowercase Latin letters and $ 1 \leq n \leq 200000 $. **Constraints** $ |s| = |t| = n $ **Objective** Determine whether there exist indices $ i, j \in \{1, \dots, n\} $ with $ i \leq j $ such that reversing the substring $ s[i:j] $ results in $ t $. That is, $$ t = s[1:i-1] + \text{reverse}(s[i:j]) + s[j+1:n] $$ Output "YES" if such $ i, j $ exist; otherwise, output "NO".
API Response (JSON)
{
  "problem": {
    "name": "E. Substring Reverse",
    "description": {
      "content": "Two strings s and t of the same length are given. Determine whether it is possible to make t from s using exactly one reverse of some its substring. The first line contains the string s, and the seco",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10175E"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Two strings s and t of the same length are given. Determine whether it is possible to make t from s using exactly one reverse of some its substring.\n\nThe first line contains the string s, and the seco...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ s, t \\in \\Sigma^n $ be two strings of equal length $ n $, where $ \\Sigma $ is the set of lowercase Latin letters and $ 1 \\leq n \\leq 200000 $.\n\n**Constraints**  \n$ |s| = |t| = ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments