How can i improve this implementation , current gives TLE , is my TC calculation right ?

Revision en2, by rickgrimes07, 2025-03-26 23:24:30

https://cses.fi/problemset/task/1139

https://cses.fi/paste/cdb7092742c2c314be200e/

DFS , TC: O(n)

m=2*n

Segment tree , build and query , O(mlogmlogm) , roughly

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English rickgrimes07 2025-03-26 23:24:30 86
en1 English rickgrimes07 2025-03-26 23:23:50 196 Initial revision (published)