No.1481 Rotation ABC
レベル :
/ AI推定難易度 : 1825
/ 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 45
作問者 :
nok0
/ テスター :
fairy_lettuce
chineristAC
ygussany
PCTprobability
タグ : / 解いたユーザー数 45
作問者 :
nok0
/ テスター :
PCTprobability
問題文最終更新日: 2021-03-21 18:11:05
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 291
(順位表)
の他の問題:
Problem Statement
There is a string $S$ of length $N$ consisting of A,B,C.
You may perform the following operation on $S$ $0$ or more times.
- Choose a triple $\left(i,j,k\right)$ such that $S_i =$
A, $S_j = $B,$S_k =$C. Replace $S_i,S_j,S_k$ withB,C,A, respectively. Here, the chosen triple $\left(i,j,k\right)$ must satisfy one of the following order relations.- $1 \le i < j < k \le N$
- $1 \le j < k < i \le N$
- $1 \le k < i < j \le N$
Output the number of distinct strings that $S$ can be after performing the operation $0$ or more times, modulo $998244353$.
Constraints
- $1\le N \le 10^5$
- $S$ is a string of length $N$ consisting of
A,B,C.
Input
$N$ $S$
Output
Output the number of distinct strings that $S$ can be after performing the operation $0$ or more times, modulo $998244353$.
Sample
Sample 1
Input
3 ABC
Output
3
Performing the operation $0$ times gives ABC, performing it $1$ time gives BCA, and performing it $2$ times gives CAB.
Sample 2
Input
5 AAAAB
Output
1
The operation cannot be performed even $1$ time.
Sample 3
Input
4 AABC
Output
8
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。