Contribution Technique on Trees ft. CF2007E : Iris and the Tree

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ม.ค. 2025

ความคิดเห็น • 13

  • @utsavaggrawal2697
    @utsavaggrawal2697 4 หลายเดือนก่อน

    Great explanation, the amount of effort you put in for the video and the website is commendable!!

  • @anupamkasturia3821
    @anupamkasturia3821 4 หลายเดือนก่อน

    Was able to solve the weighted part completey myself after fully understanding contribution technique ....great video man..please keep uploading..

  • @studyplanet4656
    @studyplanet4656 4 หลายเดือนก่อน

    Bro i really liked your approach for problem solving please continue this series , very help full for competitive coders specially for higher ones .

  • @anupamkasturia3821
    @anupamkasturia3821 4 หลายเดือนก่อน

    02:22, i guess at here in special dfs tree, for the current node x, if it is a leaf node, dis(x,x+ 1) would not be 1.. to find x + 1, we can keep going to the parent until we find a parent with sub_max_node[parent] > x.. great explanation man..

  • @DSASolutions
    @DSASolutions 4 หลายเดือนก่อน

    Helpfull

    • @cfstepofficial
      @cfstepofficial  4 หลายเดือนก่อน

      Thanks. You have some good content on your channel as well. Keep it up!

    • @DSASolutions
      @DSASolutions 4 หลายเดือนก่อน

      @@cfstepofficial Thank You

  • @aymanalali8983
    @aymanalali8983 4 หลายเดือนก่อน

    understood 👍🏻♥️

  • @yagnikdhameliya6332
    @yagnikdhameliya6332 4 หลายเดือนก่อน

    Answer to last question:
    For each edge (i, par[i]) it's contribution will be
    (subtree(i) * (n - subtree(i))).
    Do add this much for all edges to answer. Multiply weight of the edge for weighted graph.

    • @cfstepofficial
      @cfstepofficial  4 หลายเดือนก่อน +1

      Yep, that's correct.

  • @yagnikdhameliya6332
    @yagnikdhameliya6332 4 หลายเดือนก่อน +1

    I think some variables are not required.
    unlocked_sum and locked_sum are not required only one variable sum will be sufficient.
    Below assigned[v]+=w only do sum+=w and remove unblocked_sum and locked_sum from everywhere.
    At time of events your answer would be ans=sum+unlocked_count*remain
    Why?
    Because see brute force you will notice you need sum of all node's assigned[i] value and assigned [i] value is just some of w's.
    So, the "sum" is doing the same thing. Keep everything else same.
    Please correct me if i am wrong anywhere.
    Btw your explanations are too good keep it up.