第 231 场 AtCoder Regular Contest
E
奇数逆序对
Odd Inversion
AtCoder
⌀ 2393
原题
← DF →

奇数逆序对AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

You are given a sequence of positive integers $A = (A_1, A_2, \cdots, A_N)$ of length $N$. Here, $A_1 \leq A_2 \leq \cdots \leq A_N$ holds.

给定一个长度为 $N$ 的正整数序列 $A = (A_1, A_2, \cdots, A_N)$。其中满足 $A_1 \leq A_2 \leq \cdots \leq A_N$。AI (CI翻译)

Find the number, modulo $998\,244\,353$, of possible sequences of positive integers $B$ of length $N$ satisfying the following conditions.

请求出满足以下条件的长度为 $N$ 的正整数序列 $B$ 的数量,答案对 $998\,244\,353$ 取模。AI (CI翻译)

  • $1 \leq B_i \leq A_i$ ($1 \leq i \leq N$)
  • The inversion number of $B$ is odd.
  • $1 \leq B_i \leq A_i$($1 \leq i \leq N$)
  • $B$ 的逆序数为奇数。
AI (CI翻译)

Here, the inversion number of $B$ is the number of pairs of integers $(i, j)$ satisfying $1 \leq i < j \leq N$ such that $B_i > B_j$.

其中,$B$ 的逆序数是满足 $1 \leq i < j \leq N$ 且 $B_i > B_j$ 的整数对 $(i, j)$ 的数量。AI (CI翻译)

Solve $T$ test cases per input file.

每个输入文件中包含 $T$ 组测试用例,请解决每组测试用例。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $1 \leq T \leq 10\,000$
  • $1 \leq N \leq 200\,000$
  • $1 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq 10^9$
  • The sum of $N$ over the $T$ test cases is at most $400\,000$.
  • All input values are integers.
  • $1 \leq T \leq 10\,000$
  • $1 \leq N \leq 200\,000$
  • $1 \leq A_1 \leq A_2 \leq \cdots \leq A_N \leq 10^9$
  • 所有测试用例的 $N$ 之和不超过 $400\,000$。
  • 所有输入值均为整数。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

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

输入从标准输入中给出,格式如下。其中,$\mathrm{case}_i$($1 \leq i \leq T$)表示第 $i$ 组测试用例。AI (CI翻译)

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T

T
\mathrm{case}_1
\mathrm{case}_2
\vdots
\mathrm{case}_T
AI (CI翻译)

Each test case is given in the following format:

每组测试用例的格式如下:AI (CI翻译)

N
A_1 A_2 \cdots A_N

N
A_1 A_2 \cdots A_N
AI (CI翻译)

Output

输出格式

AI (CI翻译)

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

输出 $T$ 行。第 $i$ 行($1 \leq i \leq T$)应包含 $\mathrm{case}_i$ 的答案。AI (CI翻译)

样例

Input #1
3
2
2 3
3
2 2 3
5
699498 707559 724350 759726 769395
Output #1
1
3
610589585
- 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.
题目信息
题号
arc231_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。