AT_abc468_g.Restricted Permutation

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer NN and a string SS of length NN consisting of o and x.

Find the number, modulo 998244353998244353, of permutations P=(P1,P2,…,PN)P=(P_1,P_2,\ldots,P_N) of (1,2,…,N)(1,2,\ldots,N) satisfying the following condition.

  • For k=1,2,…,Nk=1,2,\ldots,N, the following two are equivalent.
    • Sk=S_k= o
    • PP contains a permutation of (1,2,…,k)(1,2,\ldots,k) as a contiguous subsequence.

给定一个整数 NN 和一个长度为 NN 的字符串 SS,其中仅包含字符 o 和 x。

求满足以下条件的排列 P=(P1,P2,…,PN)P=(P_1,P_2,\ldots,P_N)(即 (1,2,…,N)(1,2,\ldots,N) 的一个排列)的个数,答案对 998244353998244353 取模。

  • 对于 k=1,2,…,Nk=1,2,\ldots,N,以下两个命题等价:
    • Sk=S_k= o
    • PP 包含 (1,2,…,k)(1,2,\ldots,k) 的某个排列作为连续子序列。

输入格式

The input is given from Standard Input in the following format:

NN
SS

输入从标准输入中按以下格式给出:

NN
SS

输出格式

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)P=(1,3,2),(2,3,1) satisfy the condition.

Sample 2 Explanation:
There is no PP satisfying the condition.

Constraints

  • 1≤N≤20001\le N\le 2000
  • SiS_i is a string of length NN consisting of o and x.

样例 1 解释:
满足条件的 PP 有 (1,3,2)(1,3,2) 和 (2,3,1)(2,3,1)。

样例 2 解释:
不存在满足条件的 PP。

约束条件

  • 1≤N≤20001\le N\le 2000
  • SiS_i 是一个长度为 NN 的字符串,仅由字符 o 和 x 组成。

输入解题思路,AI测评打分。不知道怎么写?

首页