cf/mirror

Appending Permutations (Hard Version)

CF
2124F22800· international gm3s1024 MB⌨ stdin/stdout

Examples

Sample 1of 2multi-test • hover to link
Input
7
3 0
3 3
1 1
2 1
3 1
3 2
1 1
2 1
6 2
2 3
4 2
2 3
1 2
2 2
1 1
4 3
2 2
3 2
4 2
3 2
2 3
3 3
Output
7
0
1
65
0
4
5
Sample 2of 2multi-test • hover to link
Input
1
5000 1
69 420
Output
886908216
2124F2.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)