#P8321. 『JROI-4』沈阳大街 2
『JROI-4』沈阳大街 2
Problem Description
Given two sequences of length , satisfying:
-
.
-
.
Let be a permutation of length . Define the value function :
All permutations are equally likely. Find the expected value of modulo .
That is, compute:
$$\left(\dfrac{1}{n!}\sum_\pi f(\pi)\right) \bmod 998244353$$Input Format
The first line contains an integer .
The second line contains integers, denoting .
The third line contains integers, denoting .
Output Format
Output one line containing one integer, the answer.
8
15 14 13 10 9 6 3 2
2 10 8 2 9 1 10 2
114102208
Hint
This problem uses bundled testdata.
| Subtask ID | Score | Special Constraints |
|---|---|---|
| 1 | 5 | |
| 2 | 35 | |
| 3 | 20 | |
| 4 | 40 | None |
For of the data, , .
Translated by ChatGPT 5