Shift

AtCoder
IDagc046_c
Time3000ms
Memory256MB
Difficulty
Given is a string $S$ consisting of `0` and `1`. Find the number of strings, modulo $998244353$, that can result from applying the following operation on $S$ between $0$ and $K$ times (inclusive): * Choose a pair of integers $i, j$ $(1\leq i < j\leq |S|)$ such that the $i$\-th and $j$\-th characters of $S$ are `0` and `1`, respectively. Remove the $j$\-th character from $S$ and insert it to the immediate left of the $i$\-th character. ## Constraints * $1 \leq |S| \leq 300$ * $0 \leq K \leq 10^9$ * $S$ consists of `0` and `1`. ## Input Input is given from Standard Input in the following format: $S$ $K$ [samples]
Samples
Input #1
0101 1
Output #1
4

Four strings, `0101`, `0110`, `1001`, and `1010`, can result.
Input #2
01100110 2
Output #2
14
Input #3
1101010010101101110111100011011111011000111101110101010010101010101 20
Output #3
113434815
API Response (JSON)
{
  "problem": {
    "name": "Shift",
    "description": {
      "content": "Given is a string $S$ consisting of `0` and `1`. Find the number of strings, modulo $998244353$, that can result from applying the following operation on $S$ between $0$ and $K$ times (inclusive): * ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 3000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "agc046_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Given is a string $S$ consisting of `0` and `1`. Find the number of strings, modulo $998244353$, that can result from applying the following operation on $S$ between $0$ and $K$ times (inclusive):\n\n* ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments