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

建议使用的浏览器:

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

5719:Arrange

题目描述
Accidentally, Cupid, god of desire has hurt himself with his own dart and fallen in love with Psyche.

This has drawn the fury of his mother, Venus. The goddess then throws before Psyche a great mass of mixed crops.

There are $ n $ heaps of crops in total, numbered from $ 1 $ to $ n $.

Psyche needs to arrange them in a certain order, assume crops on the $ i $-th position is $ A_i $.

She is given some information about the final order of the crops:

1. the minimum value of $ A_1, A_2, ..., A_i $ is $ B_i $.

2. the maximum value of $ A_1, A_2, ..., A_i $ is $ C_i $.

She wants to know the number of valid permutations. As this number can be large, output it modulo $ 998244353 $.

Note that if there is no valid permutation, the answer is $ 0 $.
输入解释
The first line of input contains an integer $ T $ $ (1 \le T \le 15) $, which denotes the number of testcases.

For each test case, the first line of input contains single integer $ n $ $ (1 \le n \le 10 ^ 5) $.

The second line contains $ n $ integers, the $ i $-th integer denotes $ B_i $ $ (1 \le B_i \le n) $.

The third line contains $ n $ integers, the $ i $-th integer denotes $ C_i $ $ (1 \le C_i \le n) $.
输出解释
For each testcase, print the number of valid permutations modulo $ 998244353 $.
输入样例
2
3
2 1 1
2 2 3
5
5 4 3 2 1
1 2 3 4 5
输出样例
1
0

提示
In the first example, there is only one valid permutation (2,1,3) .

In the second example, it is obvious that there is no valid permutation.
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5719

最后修改于 2020-10-25T23:25:04+00:00 由爬虫自动更新

共提交 0

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