cf/mirror

Small Permutation Problem (Hard Version)

CF
1909F22500· grandmaster2s256 MB⌨ stdin/stdout

Examples

Sample 1of 1multi-test • hover to link
Input
10
5
-1 -1 -1 -1 -1
5
1 2 3 4 5
6
0 2 2 2 -1 -1
6
-1 -1 -1 -1 -1 5
6
-1 -1 3 2 -1 -1
15
0 0 -1 -1 -1 2 2 -1 -1 -1 -1 9 11 13 15
6
0 2 2 2 4 6
6
0 1 3 4 5 5
6
1 2 3 2 4 6
15
0 0 1 1 1 2 3 4 5 6 7 9 11 13 15
Output
120
1
4
0
0
494403526
4
0
0
532305727
1909F2.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)