Codeforces Round 925 (Div. 3) | D. Divisible Pairs

Поделиться
HTML-код
  • Опубликовано: 14 ноя 2024

Комментарии • 11

  • @yogendra33
    @yogendra33 9 месяцев назад +1

    good explanation

  • @shivammishra6220
    @shivammishra6220  9 месяцев назад

    I can understand your problem, it's a different type of problem, but I will try to explain you.
    We are not interested in v[i], but we are interested in vi%x and vi%y. So first perform this operation on each element, so each element will break in a pair {a ,b}i.
    If pair{ai,bi} can make a good pair with {aj, bj} then (ai+aj)%x=0 and (bi-bj)%y=0.
    So use this property. If we have a pair{aj,bj} we can compute corresponding pari(ai,bi) . If it is already in map then we we can get it in logn time.
    I hope it will help you.

    • @AnkitRaj-zm3me
      @AnkitRaj-zm3me 9 месяцев назад +1

      thanks for help.but how will we search because for each iteration there will be different element.

    • @shivammishra6220
      @shivammishra6220  9 месяцев назад

      @@AnkitRaj-zm3me fir each vi we convert it in pair of {a,b} and then we will calculat desired {aj,bj}. If it is in 0....i-1 index, then we will get from map because after each iteration we are storing vi--> {ai, bi} in map.

    • @AnkitRaj-zm3me
      @AnkitRaj-zm3me 9 месяцев назад +1

      @@shivammishra6220 finally understood the solution in evening . i do not understand why it too long to understand it.

  • @AnkitRaj-zm3me
    @AnkitRaj-zm3me 9 месяцев назад +1

    found it difficult to understand and grasp the logic , what should i do for this problem? tried different editorials but could not get it fully.

    • @shivammishra6220
      @shivammishra6220  9 месяцев назад

      I can understand your problem, it's a different type of problem, but I will try to explain you.
      We are not interested in v[i], but we are interested in vi%x and vi%y. So first perform this operation on each element, so each element will break in a pair {a ,b}i.
      If pair{ai,bi} can make a good pair with {aj, bj} then (ai+aj)%x=0 and (bi-bj)%y=0.
      So use this property. If we have a pair{aj,bj} we can compute corresponding pari(ai,bi) . If it is already in map then we we can get it in logn time.
      I hope it will help you.

  • @FaisalMalik-e3d
    @FaisalMalik-e3d 8 месяцев назад

    good explanation but why did you use plus x in eq ((x-a)+x )%x. only point i didn't understand and u didn't explain this on paper but you used it in your code

    • @shivammishra6220
      @shivammishra6220  8 месяцев назад

      In some cases (X-a) may be negative , so just for the safety purpose we have added extra X and then taken it's mod.

  • @SamsIt-hi9gf
    @SamsIt-hi9gf 9 месяцев назад

    was this round rated?