当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7221:Darkmoon Faire

题目描述
$\space \space$ *Ahead of You, Down the Path*

$\space \space$ *A Majestic, Magical Faire!*

$\space \space$ *Ignore the Darkened, Eerie Woods*

$\space \space$ *Ignore the Eyes That Blink and Stare*

$\space \space$ *Fun & Games & Wondrous Sights!*

$\space \space$ *Music & Fireworks to Light Up the Night!*

$\space \space$ *Do Not Stop! You're Nearly There!*

$\space \space$ *Behold, My Friend: THE DARKMOON FAIRE!*

One day, you go to the Darkmoon Faire with your friends.

You begin to play a game called "Finding the Ridiculous Partitions"!

An array is "ridiculous", if the maximum element of the array lies on an odd index, while the minimum element of the array lies on an even index.

You are given a sequence $a$ of length $n$. It's guaranteed that all $a_i$ are pairwise distinct.

You can partition the sequence into several (probably one) continuous intervals, such that the intervals don't intersect and that every position belongs to exactly one interval. For every interval, we can view it as a one-based array. A partition is "ridiculous", if for each of the intervals, its corresponding array is ridiculous.

Please calculate the number of "ridiculous partitions" of the given sequence.

Since the answer can be very large, you only need to output the answer modulo 998244353.
输入解释
The input consists of multiple test cases.

The first line contains an integer $T\ (1\leq T\leq 5)$ denoting the number of test cases.

For each test case, the first line contains a single integer $n\ (1 \leq n \leq 3\times 10^5)$.

The second line contains $n$ integers $a_i\ (1 \leq a_i \leq 10^9)$, it's guaranteed that $a_i \neq a_j$ for all $i\neq j$.

The sum of $n$ over all test cases does not exceed $10^6$.
输出解释
For each test case, output one line containing the answer modulo 998244353.
输入样例
2
5
3 2 4 1 8
10
9 1 2 4 7 3 6 8 10 5
输出样例
2
5

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7221

最后修改于 2022-09-15T06:17:28+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
8000/4000MS(Java/Others) 524288/524288K(Java/Others)