Swap Characters

AtCoder
IDarc168_c
Time2000ms
Memory256MB
Difficulty
You are given a string $S$ of length $N$ consisting of the characters `A`, `B`, and `C`. Consider performing the following operation between $0$ and $K$ times, inclusive: * Freely choose two characters in $S$ and swap them. Find the number of strings that $S$ can be after the operations, modulo $998244353$. ## Constraints * $1 \leq N \leq 250000$ * $1 \leq K \leq 100$ * $S$ is a string of length $N$ consisting of the characters `A`, `B`, and `C`. * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $K$ $S$ [samples]
Samples
Input #1
3 1
ABC
Output #1
4

The following four strings can be obtained:

*   $S=$`ABC`: No operation is needed.
*   $S=$`BAC`: Swap the $1$\-st and $2$\-nd characters.
*   $S=$`CBA`: Swap the $1$\-st and $3$\-rd characters.
*   $S=$`ACB`: Swap the $2$\-nd and $3$\-rd characters.
Input #2
3 2
ABC
Output #2
6
Input #3
4 5
AAAA
Output #3
1
Input #4
30 10
CACCABAABBABABBCBBCAAACAAACCCA
Output #4
42981885
API Response (JSON)
{
  "problem": {
    "name": "Swap Characters",
    "description": {
      "content": "You are given a string $S$ of length $N$ consisting of the characters `A`, `B`, and `C`. Consider performing the following operation between $0$ and $K$ times, inclusive: *   Freely choose two charac",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "arc168_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a string $S$ of length $N$ consisting of the characters `A`, `B`, and `C`.\nConsider performing the following operation between $0$ and $K$ times, inclusive:\n\n*   Freely choose two charac...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments