AT_abc468_g.Restricted Permutation
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer N and a string S of length N consisting of o and x.
Find the number, modulo 998244353, of permutations P=(P1,P2,…,PN) of (1,2,…,N) satisfying the following condition.
- For k=1,2,…,N, the following two are equivalent.
- Sk=
o - P contains a permutation of (1,2,…,k) as a contiguous subsequence.
- Sk=
给定一个整数 N 和一个长度为 N 的字符串 S,其中仅包含字符 o 和 x。
求满足以下条件的排列 P=(P1,P2,…,PN)(即 (1,2,…,N) 的一个排列)的个数,答案对 998244353 取模。
- 对于 k=1,2,…,N,以下两个命题等价:
- Sk=
o - P 包含 (1,2,…,k) 的某个排列作为连续子序列。
- Sk=
输入格式
The input is given from Standard Input in the following format:
N
S
输入从标准输入中按以下格式给出:
N
S
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
3 oxo
输出#1
2
输入#2
7 xxxxxxx
输出#2
0
输入#3
15 oxxxoxxxxxooxxo
输出#3
1627648
说明/提示
Sample 1 Explanation:
P=(1,3,2),(2,3,1) satisfy the condition.
Sample 2 Explanation:
There is no P satisfying the condition.
Constraints
- 1≤N≤2000
- Si is a string of length N consisting of
oandx.
样例 1 解释:
满足条件的 P 有 (1,3,2) 和 (2,3,1)。
样例 2 解释:
不存在满足条件的 P。
约束条件
- 1≤N≤2000
- Si 是一个长度为 N 的字符串,仅由字符
o和x组成。
输入解题思路,AI测评打分。不知道怎么写?