Universal Cup Judging System

Universal Cup

時間限制: 2.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

Descrizione

C'è una stringa $S$ di lunghezza $N$ composta da lettere maiuscole dell'alfabeto inglese. Puoi eseguire la seguente operazione su $S$ un numero qualsiasi di volte:

  • Scegli una quadrupla di interi $(i, j, k, l)$ tale che $1 \le i < j < k < l \le |S|$, $S_i = \text{K}$, $S_j = \text{U}$, $S_k = \text{P}$ e $S_l = \text{C}$. Sostituisci tutti gli elementi $S_i, S_j, S_k, S_l$ con $\text{X}$, e guadagna $(i \times j \times k \times l)$ yen.

Trova la quantità massima di denaro che può essere guadagnata in totale, modulo $998244353$.

Input

La prima riga contiene un intero $N$ ($1 \le N \le 5 \times 10^5$). La seconda riga contiene una stringa $S$ di lunghezza $N$ composta da lettere maiuscole dell'alfabeto inglese.

Output

Stampa la risposta.

Esempi

Input 1

10
KKUPCUCAPC

Output 1

1164

Input 2

4
TUNA

Output 2

0

Input 3

30
KUCCKCKKPUKUPCUCPUCKPCKKUUPCPK

Output 3

619704

Note

Nota che ti viene chiesto il resto del valore massimo, non il massimo resto possibile. Per il primo esempio, puoi guadagnare 1164 yen eseguendo le seguenti operazioni:

  • Scegli $(i, j, k, l) = (1, 3, 4, 7)$. Guadagni $1 \times 3 \times 4 \times 7 = 84$ yen. Allora $S = \text{XKXXCUXAPC}$.
  • Scegli $(i, j, k, l) = (2, 6, 9, 10)$. Guadagni $2 \times 6 \times 9 \times 10 = 1080$ yen. Allora $S = \text{XXXXCXXXAXX}$.

Si può dimostrare che è impossibile guadagnare più di 1164 yen, quindi stampa 1164. Per il secondo esempio, non è possibile eseguire alcuna operazione nemmeno una volta, quindi stampa 0.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1533EditorialOpen题解jianglyView

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.