AT_awtf2026algo_b.Window Records
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a sequence of positive integers of length N, A=(A1,A2,…,AN). Find, modulo 998244353, the number of sequences of positive integers of length N, x=(x1,x2,…,xN), satisfying all of the following conditions.
- xi≤Ai holds for all i.
- There exists a permutation p=(p1,p2,…,p2N−1) of (1,2,…,2N−1) satisfying the following condition.
- For each i (1≤i≤N), consider the sequence of length N, (pi,pi+1,…,pi+N−1). There are exactly xi different values that are "prefix max" of this sequence. More precisely, the number of indices j (i≤j≤i+N−1) such that pj=maxi≤k≤jpk is xi.
给你一个长度为 N 的正整数序列 A=(A1,A2,…,AN)。求满足以下所有条件的、长度为 N 的正整数序列 x=(x1,x2,…,xN) 的个数(对 998244353 取模):
- 对所有 i,均有 xi≤Ai;
- 存在一个 (1,2,…,2N−1) 的排列 p=(p1,p2,…,p2N−1),满足如下条件:
- 对每个 i(1≤i≤N),考虑长度为 N 的子序列 (pi,pi+1,…,pi+N−1)。该子序列中恰好有 xi 个值是“前缀最大值”。更准确地说,满足 pj=maxi≤k≤jpk 的下标 j(其中 i≤j≤i+N−1)的个数恰好为 xi。
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
输入从标准输入中按以下格式给出:
N
A1 A2 … AN
输出格式
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). The condition is satisfied by p=(2,3,1).
There are four possible values of x: (1,1),(1,2),(2,1),(2,2).
Sample 3 Explanation:
For example, consider x=(3,1,3). No choice of p satisfies the conditions.
Constraints
- 2≤N≤50
- 1≤Ai≤N
- All input values are integers.
样例 1 解释:
例如,考虑 x=(2,1)。此时 p=(2,3,1) 满足条件。
共有四种可能的 x 值:(1,1),(1,2),(2,1),(2,2)。
样例 3 解释:
例如,考虑 x=(3,1,3)。不存在满足条件的 p。
限制条件
- 2≤N≤50
- 1≤Ai≤N
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?