AT_ndpc2026_i.Update Positions

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

For a sequence B=(B1,B2,…,BN)B = (B_1, B_2, \dots, B_N) of length NN, define prefix max update positions and suffix max update positions as follows:

  • An index ii is called a prefix max update position if for all 1≤j<i1 \leq j < i, we have Bj<BiB_j < B_i.
  • An index ii is called a suffix max update position if for all i<j≤Ni < j \leq N, we have Bj<BiB_j < B_i.

You are given a sequence A=(A1,A2,…,AN)A = (A_1, A_2, \dots, A_N) of length NN, and integers LL and RR.

Consider all sequences obtained by rearranging the elements of AA. Among them, count how many sequences have exactly LL prefix max update positions and exactly RR suffix max update positions. Output the answer modulo 998244353998244353.

Two sequences are considered the same if they are identical as sequences.

对于一个长度为 NN 的序列 B=(B1,B2,…,BN)B = (B_1, B_2, \dots, B_N),定义其前缀最大值更新位置与后缀最大值更新位置如下:

  • 若对所有满足 1≤j<i1 \leq j < i 的 jj 均有 Bj<BiB_j < B_i,则称下标 ii 为一个前缀最大值更新位置;
  • 若对所有满足 i<j≤Ni < j \leq N 的 jj 均有 Bj<BiB_j < B_i,则称下标 ii 为一个后缀最大值更新位置。

给定一个长度为 NN 的序列 A=(A1,A2,…,AN)A = (A_1, A_2, \dots, A_N),以及两个整数 LL 和 RR。

考虑所有由 AA 的元素重排得到的序列。在这些序列中,统计恰好具有 LL 个前缀最大值更新位置且恰好具有 RR 个后缀最大值更新位置的序列个数。答案对 998244353998244353 取模。

若两个序列作为序列完全相同,则视为同一个序列。

输入格式

The input is given from standard input in the following format:

NN LL RR
A1A_1 A2A_2 …\dots ANA_N

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

NN LL RR
A1A_1 A2A_2 …\dots ANA_N

输出格式

Print the number of sequences satisfying the conditions, modulo 998244353998244353.

输出满足条件的序列数量,对 998244353998244353 取模。

输入输出样例

  • 输入#1

    4 2 1
    1 2 3 4

    输出#1

    2
  • 输入#2

    10 3 2
    6 10 4 1 5 9 8 6 5 1

    输出#2

    50424

说明/提示

Sample 1 Explanation:
There are 22 such sequences:

  • (3,2,1,4)(3,2,1,4)
  • (3,1,2,4)(3,1,2,4)

Constraints

  • 1≤N≤4001 \leq N \leq 400
  • 1≤L≤N1 \leq L \leq N
  • 1≤R≤N1 \leq R \leq N
  • 1≤Ai≤N1 \leq A_i \leq N
  • All input values are integers

样例 1 解释:
满足条件的序列共有 22 个:

  • (3,2,1,4)(3,2,1,4)
  • (3,1,2,4)(3,1,2,4)

约束条件

  • 1≤N≤4001 \leq N \leq 400
  • 1≤L≤N1 \leq L \leq N
  • 1≤R≤N1 \leq R \leq N
  • 1≤Ai≤N1 \leq A_i \leq N
  • 所有输入值均为整数

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

首页