Universal Cup Judging System

Universal Cup

Límite de tiempo: 3.0 s Límite de memoria: 1024 MB Puntuación total: 100 Hackeable ✓
Estadísticas

给定一个整数 $N$ 和一个长度为 $N - 1$、由字符 <> 组成的字符串 $S$。 令 $P = (P_1, P_2, \dots, P_N)$ 为 $(1, 2, \dots, N)$ 的一个排列。 如果排列 $P$ 满足以下条件,则称其为“好排列”(Good Permutation):

  • 对于每个 $i$ ($1 \le i \le N - 1$),如果 $S$ 的第 $i$ 个字符是 <,则 $P_i < P_{i+1}$;如果是 >,则 $P_i > P_{i+1}$。

如果排列 $P$ 满足以下条件,则称其为“极好排列”(Wonderful Permutation):

  • $P$ 是一个好排列。
  • 满足 $|P_i - P_{i+1}| = 1$ 的下标 $i$ ($1 \le i \le N - 1$) 的数量在所有好排列中达到最大值。

你的任务是计算极好排列的数量,结果对 998244353 取模。

输入格式

输入按以下格式给出:

$N$ $S$

  • $N$ 是一个整数。
  • $2 \le N \le 2 \times 10^5$
  • $S$ 是一个长度为 $N - 1$、由 <> 组成的字符串。

输出格式

输出一行答案。

样例

输入格式 1

5
<<>>

输出格式 1

2

输入格式 2

40
<<>><>><>>>><><<><><><<>><<<<>><><<<>><

输出格式 2

535474657

说明

在第一个测试用例中,$(1, 2, 5, 4, 3)$ 和 $(2, 3, 5, 4, 1)$ 是好排列。满足 $|P_i - P_{i+1}| = 1$ 的 $i$ 的数量分别为 3 和 2。 我们可以证明,在所有好排列中,满足 $|P_i - P_{i+1}| = 1$ 的 $i$ 的最大数量为 3,且极好排列为 $(1, 2, 5, 4, 3)$ 和 $(3, 4, 5, 2, 1)$。

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.