ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1553. Caves and Tunnels

Heavy-Light-Decomposition -> GOOD data structure! thank you all!
sqrt(n) decomposition also works here (0.5 sec) and easier to implement
it's actually does not differ much because heavy-light with segment/fenvick over chains will be something like Q*log^2(N) with bad constant over it
Actually it was the other way around :) except for ram usage
SQRT: 0.437    11 532 KB
HLD:  0.296    14 784 KB