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
| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3447 |
| 6 | Um_nik | 3387 |
| 7 | heuristica | 3322 |
| 8 | turmax | 3317 |
| 9 | tourist | 3307 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 156 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 141 |
| 5 | Errichto | 139 |
| 6 | adamant | 137 |
| 7 | AmShZ | 136 |
| 8 | BledDest | 132 |
| 9 | maroonrk | 131 |
| 10 | qwexd | 129 |
How can i improve this implementation , current gives TLE , is my TC calculation right ?
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
| Rev. | Lang. | By | When | Δ | Comment | |
|---|---|---|---|---|---|---|
| en2 |
|
rickgrimes07 | 2025-03-26 23:24:30 | 86 | ||
| en1 |
|
rickgrimes07 | 2025-03-26 23:23:50 | 196 | Initial revision (published) |
| Name |
|---|


