cf/mirror

Medium Demon Problem (hard version)

CF
2044G21900· candidate master2s256 MB⌨ stdin/stdout

Examples

Sample 1of 1multi-test • hover to link
Input
5
2
2 1
5
2 3 4 5 1
5
2 1 4 2 3
5
4 1 1 5 4
10
4 3 9 1 6 7 9 10 10 3
Output
2
2
5
5
5
2044G2.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)
loading graph engine…