問題一覧 > 通常問題

No.171 Swap String (Med)

レベル : / 実行時間制限 : 1ケース 1.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 208
作問者 : なお
お気に入りにしたユーザー ProblemId : 414 / 自分の提出
問題文最終更新日: 2026-06-25 18:11:04
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 93 (順位表) の他の問題:

Problem Statement

A string $S$ of at most $1000$ characters is given as input.
When you may perform the operation "swap any $2$ adjacent characters" on the characters forming this string $S$ any number of times,
find the number of distinct strings that can be made, $\mod 573$.

However, the string identical to the input string $S$ is not counted.
Note that $573$ is not a prime number.

Input

S

The string $S$ is given on the $1$st line. $( 1 \leq |S| \leq 1000 ) $
The string $S$ consists only of uppercase letters ('A'–'Z').

Output

Output, as an integer, the remainder when the number of distinct strings that can be made by the operation in the problem statement (excluding the input string $S$ itself) is divided by $573$.

Sample

Sample 1
Input
ABC
Output
5

The strings that can be made by swapping $2$ adjacent characters of the string "ABC" some number of times are the following $6$.
ABC ACB
BAC BCA
CAB CBA
However, the input string itself is not counted, so excluding "ABC", $5$ kinds can be made.

Sample 2
Input
DDDDDD
Output
0

No matter how many times you swap, nothing other than "DDDDDD" can be made.
The input string itself is not counted, so excluding "DDDDDD", the answer is $0$ kinds.

Sample 3
Input
ABCDEFGHIJKLMNOPQRSTUVWXYZ
Output
551

$403291461126605635583999999$ kinds of strings can be made.
Do not forget the $\mod 573$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。