Deque Minimization

AtCoder
IDarc153_e
Time5000ms
Memory256MB
Difficulty
For a positive integer $X$ none of whose digits is $0$, consider obtaining a positive integer $Y$ as follows. * Initialize $S$ as an empty string. * Let $N$ be the number of digits in $X$. For $i = 1, \ldots, N$ in this order, do the following: insert the $i$\-th character in the decimal notation of $X$ at the beginning or end of $S$. * Let $Y$ be the positive integer represented by the string $S$. Let $f(X)$ denote the minimum positive integer that can be obtained from $X$ in this way. * * * You are given a positive integer $Y$ none of whose digits is $0$. Print the number, modulo $998244353$, of positive integers $X$ none of whose digits is $0$ such that $f(X) = Y$. ## Constraints * $Y$ is a positive integer none of whose digits is $0$. * $1\leq Y < 10^{200000}$ ## Input The input is given from Standard Input in the following format: $Y$ [samples]
Samples
Input #1
1332
Output #1
3

Three integers, $1332$, $3132$, and $3312$, satisfy the conditions.
Input #2
3312
Output #2
0
Input #3
12234433442
Output #3
153
API Response (JSON)
{
  "problem": {
    "name": "Deque Minimization",
    "description": {
      "content": "For a positive integer $X$ none of whose digits is $0$, consider obtaining a positive integer $Y$ as follows. *   Initialize $S$ as an empty string. *   Let $N$ be the number of digits in $X$. For $i",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 5000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc153_e"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "For a positive integer $X$ none of whose digits is $0$, consider obtaining a positive integer $Y$ as follows.\n\n*   Initialize $S$ as an empty string.\n*   Let $N$ be the number of digits in $X$. For $i...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments