Блог пользователя mrTux

Автор mrTux, 10 лет назад, По-английски

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.

Теги lca
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится
»
10 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

This problem only asks for LCA link

  • »
    »
    10 лет назад, # ^ |
    Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

    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 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      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 лет назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

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

      • »
        »
        »
        »
        10 лет назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        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 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

From Codeforces: this and this.

  • »
    »
    10 лет назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    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 лет назад, # ^ |
      Rev. 3   Проголосовать: нравится 0 Проголосовать: не нравится

      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.