mrTux's blog

By mrTux, 10 years ago, In English

some times ago i learned LCA and now i am looking for some problems which are solved by the idea to find lca by segment tree to absorb the idea better.does anybody have a suggestion??if you wanna read more about this idea you can read the LCA article in topcoder.

Tags lca
  • Vote: I like it
  • 0
  • Vote: I do not like it

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it
»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

This problem only asks for LCA link

  • »
    »
    10 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    thank you for your help but i've solved it and some other LCA problems before but now i am looking for some problems which include a higher idea and of course harder algorithms, finding LCA by SEGMENT TREE not the one's which can be solved by the usual LCA idea. if you wanna read more about this idea you can read the LCA article in topcoder.

    • »
      »
      »
      10 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Bruteforce for LCA got TLE with me in this problem maybe because big number of test cases

      Anyway you can test whatever algorithm you want even the constraints are low

    • »
      »
      »
      10 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      if you learn Dynamic Trees you will can solve this problem, LCA in a dynamic tree with operations like Link or Cut.

      • »
        »
        »
        »
        10 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        thank you very much,i've seen some problems like this before but i didn't have any idea how to solve it.and now looks like i've found a new way to think about them.

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

From Codeforces: this and this.

  • »
    »
    10 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    I think you dont need LCA in 191C(first link) I solved it without LCA and I don't know to solve it with LCA.

    • »
      »
      »
      10 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      Can you please explain how to solve it without LCA? to solve it using LCA we have to make it rooted tree, let's vertex 0 is a root. For each x and y find z = LCA(x, y) Add(0, z, -2) Add(z, x, 1) Add(z, y, 1). Add( a, b, value) — Add value to all edges on the path from a to b. All queries Add we can perform offline using only one DFS.