AT_awtf2026algo_b.Window Records

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a sequence of positive integers of length NN, A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N). Find, modulo 998244353998244353, the number of sequences of positive integers of length NN, x=(x1,x2,…,xN)x=(x_1,x_2,\ldots,x_N), satisfying all of the following conditions.

  • xi≤Aix_i \leq A_i holds for all ii.
  • There exists a permutation p=(p1,p2,…,p2N−1)p=(p_1,p_2,\ldots,p_{2N-1}) of (1,2,…,2N−1)(1,2,\ldots,2N-1) satisfying the following condition.
    • For each ii (1≤i≤N1 \leq i \leq N), consider the sequence of length NN, (pi,pi+1,…,pi+N−1)(p_i,p_{i+1},\ldots,p_{i+N-1}). There are exactly xix_i different values that are "prefix max" of this sequence. More precisely, the number of indices jj (i≤j≤i+N−1i \leq j \leq i+N-1) such that pj=max⁡i≤k≤jpkp_j = \max_{i \leq k \leq j} p_k is xix_i.

给你一个长度为 NN 的正整数序列 A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N)。求满足以下所有条件的、长度为 NN 的正整数序列 x=(x1,x2,…,xN)x=(x_1,x_2,\ldots,x_N) 的个数(对 998244353998244353 取模):

  • 对所有 ii,均有 xi≤Aix_i \leq A_i;
  • 存在一个 (1,2,…,2N−1)(1,2,\ldots,2N-1) 的排列 p=(p1,p2,…,p2N−1)p=(p_1,p_2,\ldots,p_{2N-1}),满足如下条件:
    • 对每个 ii(1≤i≤N1 \leq i \leq N),考虑长度为 NN 的子序列 (pi,pi+1,…,pi+N−1)(p_i,p_{i+1},\ldots,p_{i+N-1})。该子序列中恰好有 xix_i 个值是“前缀最大值”。更准确地说,满足 pj=max⁡i≤k≤jpkp_j = \max_{i \leq k \leq j} p_k 的下标 jj(其中 i≤j≤i+N−1i \leq j \leq i+N-1)的个数恰好为 xix_i。

输入格式

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

NN
A1A_1 A2A_2 …\ldots ANA_N

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

NN
A1A_1 A2A_2 …\ldots ANA_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    2
    2 2

    输出#1

    4
  • 输入#2

    2
    1 2

    输出#2

    2
  • 输入#3

    3
    3 3 3

    输出#3

    20
  • 输入#4

    4
    3 2 4 3

    输出#4

    44
  • 输入#5

    10
    8 3 8 10 1 5 3 1 6 4

    输出#5

    2590
  • 输入#6

    50
    29 43 38 17 46 49 39 39 48 27 35 46 50 25 47 38 25 38 32 22 50 42 47 37 26 50 37 30 44 49 22 38 35 44 50 44 46 46 41 48 32 15 6 32 49 37 38 45 33 31

    输出#6

    969185665

说明/提示

Sample 1 Explanation:
For example, consider x=(2,1)x=(2,1). The condition is satisfied by p=(2,3,1)p=(2,3,1).

There are four possible values of xx: (1,1),(1,2),(2,1),(2,2)(1,1),(1,2),(2,1),(2,2).

Sample 3 Explanation:
For example, consider x=(3,1,3)x=(3,1,3). No choice of pp satisfies the conditions.

Constraints

  • 2≤N≤502 \leq N \leq 50
  • 1≤Ai≤N1 \leq A_i \leq N
  • All input values are integers.

样例 1 解释:
例如,考虑 x=(2,1)x=(2,1)。此时 p=(2,3,1)p=(2,3,1) 满足条件。

共有四种可能的 xx 值:(1,1),(1,2),(2,1),(2,2)(1,1),(1,2),(2,1),(2,2)。

样例 3 解释:
例如,考虑 x=(3,1,3)x=(3,1,3)。不存在满足条件的 pp。

限制条件

  • 2≤N≤502 \leq N \leq 50
  • 1≤Ai≤N1 \leq A_i \leq N
  • 所有输入值均为整数。

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

首页