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)A = (A_1, A_2, \cdots, A_N) of length NN. Here, A1≤A2≤⋯≤ANA_1 \leq A_2 \leq \cdots \leq A_N holds.

Find the number, modulo 998 244 353998\,244\,353, of possible sequences of positive integers BB of length NN satisfying the following conditions.

  • 1≤Bi≤Ai1 \leq B_i \leq A_i (1≤i≤N1 \leq i \leq N)
  • The inversion number of BB is odd.

Here, the inversion number of BB is the number of pairs of integers (i,j)(i, j) satisfying 1≤i<j≤N1 \leq i < j \leq N such that Bi>BjB_i > B_j.

Solve TT test cases per input file.

给你一个长度为 NN 的正整数序列 A=(A1,A2,⋯ ,AN)A = (A_1, A_2, \cdots, A_N),满足 A1≤A2≤⋯≤ANA_1 \leq A_2 \leq \cdots \leq A_N。

求满足以下条件的长度为 NN 的正整数序列 BB 的个数(对 998 244 353998\,244\,353 取模):

  • 1≤Bi≤Ai1 \leq B_i \leq A_i(1≤i≤N1 \leq i \leq N);
  • BB 的逆序数为奇数。

其中,BB 的逆序数定义为满足 1≤i<j≤N1 \leq i < j \leq N 且 Bi>BjB_i > B_j 的整数对 (i,j)(i, j) 的个数。

每组输入文件需处理 TT 组测试用例。

输入格式

The input is given from Standard Input in the following format. Here, casei\mathrm{case}_i (1≤i≤T1 \leq i \leq T) denotes the ii-th test case.

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case is given in the following format:

NN
A1A_1 A2A_2 ⋯\cdots ANA_N

输入从标准输入中按以下格式给出。其中,casei\mathrm{case}_i(1≤i≤T1 \leq i \leq T)表示第 ii 个测试用例。

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例按以下格式给出:

NN
A1A_1 A2A_2 ⋯\cdots ANA_N

输出格式

Output TT lines. The ii-th line (1≤i≤T1 \leq i \leq T) should contain the answer for casei\mathrm{case}_i.

输出 TT 行。第 ii 行(1≤i≤T1 \leq i \leq T)应包含 casei\mathrm{case}_i 的答案。

输入输出样例

  • 输入#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)(2, 1) satisfies the conditions.
  • For the second test case, (1,2,1),(2,1,2),(2,1,3)(1, 2, 1), (2, 1, 2), (2, 1, 3) satisfy the conditions.

Constraints

  • 1≤T≤10 0001 \leq T \leq 10\,000
  • 1≤N≤200 0001 \leq N \leq 200\,000
  • 1≤A1≤A2≤⋯≤AN≤1091 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq 10^9
  • The sum of NN over the TT test cases is at most 400 000400\,000.
  • All input values are integers.

样例 1 解释:

  • 对于第一个测试用例,(2,1)(2, 1) 满足条件。
  • 对于第二个测试用例,(1,2,1)(1, 2, 1)、(2,1,2)(2, 1, 2)、(2,1,3)(2, 1, 3) 满足条件。

约束条件

  • 1≤T≤10 0001 \leq T \leq 10\,000
  • 1≤N≤200 0001 \leq N \leq 200\,000
  • 1≤A1≤A2≤⋯≤AN≤1091 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq 10^9
  • 所有 TT 个测试用例的 NN 值之和不超过 400 000400\,000。
  • 所有输入值均为整数。

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

首页