luminarae's blog

By luminarae, history, 3 months ago, In English

Hello Codeforces Community, I was recently trying to solve this problem on CSES

Following is my approach and code. Approach — Find LCA using Binary Lifting and then compute distance of a to b by doing the following depth[a] + depth[b] — 2 * depth[lca(a, b)].

Link to my code

But I am continuously getting TLE on test 6 and 7(this is not a meme, I am really having difficulty). Can someone help me with what exactly the issue is out here? Is it some large constant factor or smth else. Any help is appreciated.

Full text and comments »

  • Vote: I like it
  • +1
  • Vote: I do not like it