Problem link: 1796E - Colored Subgraphs
When solving this problem I only know how to solve for a fixed root, and it's better to let a leaf node with smaller distance to the nearest node with degree>=3 to be the root, but I don't know how to choose it. So I sort all leaves by there distance, and try first 40 of them to be the root. I've thought it could fail on some large tests but unexpectedly it got AC. Can someone hack this solution or prove it's correctness?
My submission:195462544
Update: My submission has been hacked
40 might be okay. But 8 leaves also work for some reason...?
Submission: 195470681
Interested