No.1927 AB-CD
タグ : / 解いたユーザー数 150
作問者 :
milkcoffee
/ テスター :
👑 Problem Statement
You are given a string $S$ of length $N$ consisting of A,B,C,D. You may perform the following operation on $S$ any number of times.
AB,BA,CD,DC as the $2$ adjacent characters. Then, swap the $2$ chosen characters.Find the number of strings $S$ that can be obtained by performing this operation $0$ or more times, modulo $998244353$.
Input
$N$ $S$
A,B,C,D.Output
Print, as an integer, the number of possible strings $S$ after the operations, modulo $998244353$.
Sample
Sample 1
Input
3 ABC
Output
3
The following $3$ strings are possible as $S$ after the operations.
ABC, ACB, CAB
Note that A and B cannot be swapped.
Sample 2
Input
6 CCDDCC
Output
1
The only possible $S$ after the operations is CCDDCC, which is $1$ string.
Sample 3
Input
100 BDBADDDACABABABDDADBBCBDBBDCBBCAAACCDBBDDAABAACDDAAACBCDABBCADAAABCCCAADBADBBCACADCACADAACBACCBADAAA
Output
472878571
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。