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

Автор woofwoof321, история, 5 лет назад, По-английски

I asked this from the best coder of my college and he was totally clueless and so am I. This is the question: https://codeforces.com/problemset/problem/4/A. My approach is to use a segment tree of balanced binary search trees and then apply heavy-light decomposition and binary lifting but it gives wrong answer on test 1.

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

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

Same doubt. woofwoof321

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

Please sir, help me!

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

I have also used similar approach and solved the problem. Actually you are doing it wrong you have to just create the equivalent binary tree and apply centroid decomposition on that tree. Final answer will be stored in a sparse table. I hope it helps. woofwoof321

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

    nishantwrp I tried your approach but got TLE on test 69. Your approach is quite complicated compared to mine but I can guarantee you that my code didn't have any bugs. I think the time limit in this question is too strict. Can you please give me some tips on how to squeeze this solution in the time limit?

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

      Oh I see. I had problems with that as well, got TLE a few times. I think you forgot to make your centroid decomposition persistent. Also make sure to use a lot of bitsets for speed boost. It will barely fit in the time limit. Happy to help. woofwoof321

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

        Wow! Thank you so much for your help nishantwrp!I finally got this question accepted!! Using bitsets certainly helped a lot. I am flabbergasted I couldn't think of it on my own.

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

        Thank you for such a brilliant solution. I am glad that there are coders like you to help us.

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

        .

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

        Thanks nishantwrp,this blog was really very helpful.when i first saw the question i barely could think of any approach,even after reading the tuitorial i was unable to understand the solution but your approach was very easy to understand..

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

nishantwrp Wow! Your approach is much simpler and way more intuitive than the one given in the editorial. Thanks for sharing such an awesome approach with the rest of the Codeforces community!

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

woofwoof321 , Jimmy Neutron, boy genius

»
5 лет назад, # |
Rev. 3   Проголосовать: нравится -33 Проголосовать: не нравится

Edit: sorry if I have offended anyone, I was just trying to meme it up.

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

what is this? a bullshit blog get 22 upvote?

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

I did the following: maintain a cartesian treap for each node in the graph and compute the number of hamiltonian paths after compressing the SCC's. This is a standard technique taught in my hometown of Area 69.