Logo
(追記) (追記ここまで)

32083번 - Twin Friends 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB85583769.811%

문제

You meet two new friends who are twins. The name of the elder twin is $A,ドル which consists of $N$ characters. While the name of the younger twin is $B,ドル which consists of $M$ characters. It is known that $N ≤ M$.

You want to call each of them with a nickname. For the elder twin, you want to pick any permutation of $A$ as the nickname. For the younger twin, you want to remove exactly $M - N$ characters from any permutation of $B$. Denote the nicknames of the elder twin and the younger twin as $A'$ and $B',ドル respectively.

You want the nicknames to satisfy the following requirement. For each i that satisfies 1ドル ≤ i ≤ N,ドル $B'_i$ must be equal to either $A'_i$ or the next letter that follows alphabetically after $A'_i$ (if such a next letter exists).

Determine the number of different pairs of nicknames $(A' , B' )$ that satisfy the requirement. Two pairs of nicknames are considered different if at least one of the nicknames are different. As the result might be large, find the answer modulo 998ドル,円 244,円 353$.

입력

The first line consists of two integers $N$ $M$ (1ドル ≤ N ≤ M ≤ 200,円 000$).

The second line consists of a string $A$ of length $N$.

The third line consists of a string $B$ of length $M$.

All strings consist of only upper-case letters.

출력

Output a single integer representing number of different pairs $(A' , B' )$ that satisfy the requirement, modulo 998ドル,円 244,円 353$.

제한

예제 입력 1

3 4
AMA
ANAB

예제 출력 1

9

The 9ドル$ pairs are:

  • (AAM, AAN),
  • (AAM, ABN),
  • (AAM, BAN),
  • (AMA, ANA),
  • (AMA, ANB),
  • (AMA, BNA),
  • (MAA, NAA),
  • (MAA, NAB), and
  • (MAA, NBA).

예제 입력 2

5 8
BINUS
BINANUSA

예제 출력 2

120

The 120ドル$ pairs are the pairs where $A'$ is a permutation of BINUS and $B' = A'$.

예제 입력 3

15 30
BINUSUNIVERSITY
BINANUSANTARAUNIVERSITYJAKARTA

예제 출력 3

151362308

예제 입력 4

4 4
UDIN
ASEP

예제 출력 4

0

힌트

출처

ICPC > Regionals > Asia Pacific > Indonesia > Jakarta > The 2023 ICPC Asia Jakarta Regional Contest H번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /