Another Exercise on Graphs (hard version)
2500 binary search dfs and similar dp Solve on Codeforces
stdin custom input
output
Run your code to see output here.
AI Assistant

Use "AI Analyze" or "Gen Tests" to get started.