I've tried everything I could but still didn't understand why my solution is failing. Here, is the link to my solution
https://codeforces.com/contest/734/submission/70750042
Please help. Thank you!
# | User | Rating |
---|---|---|
1 | ecnerwala | 3649 |
2 | Benq | 3581 |
3 | orzdevinwang | 3570 |
4 | Geothermal | 3569 |
4 | cnnfls_csy | 3569 |
6 | tourist | 3565 |
7 | maroonrk | 3531 |
8 | Radewoosh | 3521 |
9 | Um_nik | 3482 |
10 | jiangly | 3468 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 161 |
4 | TheScrasse | 159 |
5 | nor | 158 |
6 | maroonrk | 156 |
7 | -is-this-fft- | 152 |
8 | SecondThread | 147 |
9 | orz | 146 |
10 | pajenegod | 145 |
I've tried everything I could but still didn't understand why my solution is failing. Here, is the link to my solution
https://codeforces.com/contest/734/submission/70750042
Please help. Thank you!
This is my first blog on codeforces so please don't be rude :)
I'm facing some issues while solving a problem. The problem is you have to find a path between two nodes in an undirected tree. And the approach i came up with is find the lca of node 'A' and 'B' and then print the path from node 'A' to lca and then from the next node after lca to node 'B'.
For example consider the above picture, you can see that node A = 8, node B = 10,
lca(A, B) = 4.
I can find lca(A, B) using sparse table but the problem is how can i find path from node 'A' to lca and the path from node 'B' to lca. I know i can do a dfs for finding the path but thats brute force i need a more efficient solution. What i want to say is that i need an algorithm that will only check path 8->1->2->->4->5 and not 4->7->10 if node A = 8, node B = 9 & lca(A, B) = 5. Can i use dfs ordering? If so then how? Thanks in advance!
Name |
---|