AT_arc231_e.Odd Inversion
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a sequence of positive integers A=(A1,A2,⋯,AN) of length N. Here, A1≤A2≤⋯≤AN holds.
Find the number, modulo 998244353, of possible sequences of positive integers B of length N satisfying the following conditions.
- 1≤Bi≤Ai (1≤i≤N)
- The inversion number of B is odd.
Here, the inversion number of B is the number of pairs of integers (i,j) satisfying 1≤i<j≤N such that Bi>Bj.
Solve T test cases per input file.
给你一个长度为 N 的正整数序列 A=(A1,A2,⋯,AN),满足 A1≤A2≤⋯≤AN。
求满足以下条件的长度为 N 的正整数序列 B 的个数(对 998244353 取模):
- 1≤Bi≤Ai(1≤i≤N);
- B 的逆序数为奇数。
其中,B 的逆序数定义为满足 1≤i<j≤N 且 Bi>Bj 的整数对 (i,j) 的个数。
每组输入文件需处理 T 组测试用例。
输入格式
The input is given from Standard Input in the following format. Here, casei (1≤i≤T) denotes the i-th test case.
T
case1
case2
⋮
caseT
Each test case is given in the following format:
N
A1 A2 ⋯ AN
输入从标准输入中按以下格式给出。其中,casei(1≤i≤T)表示第 i 个测试用例。
T
case1
case2
⋮
caseT
每个测试用例按以下格式给出:
N
A1 A2 ⋯ AN
输出格式
Output T lines. The i-th line (1≤i≤T) should contain the answer for casei.
输出 T 行。第 i 行(1≤i≤T)应包含 casei 的答案。
输入输出样例
输入#1
3 2 2 3 3 2 2 3 5 699498 707559 724350 759726 769395
输出#1
1 3 610589585
说明/提示
Sample 1 Explanation:
- For the first test case, (2,1) satisfies the conditions.
- For the second test case, (1,2,1),(2,1,2),(2,1,3) satisfy the conditions.
Constraints
- 1≤T≤10000
- 1≤N≤200000
- 1≤A1≤A2≤⋯≤AN≤109
- The sum of N over the T test cases is at most 400000.
- All input values are integers.
样例 1 解释:
- 对于第一个测试用例,(2,1) 满足条件。
- 对于第二个测试用例,(1,2,1)、(2,1,2)、(2,1,3) 满足条件。
约束条件
- 1≤T≤10000
- 1≤N≤200000
- 1≤A1≤A2≤⋯≤AN≤109
- 所有 T 个测试用例的 N 值之和不超过 400000。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?