Пожалуйста, подпишитесь на официальный канал Codeforces в Telegram по ссылке https://t.me/codeforces_official. ×

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

Автор Aspergillus, история, 4 часа назад, По-английски

Hi the following was asked by Adobe on an OA a day ago. The OA is over.

You are given a tree of n nodes and each node has a number associated with it. These numbers range from 1 to n, inclusive. You have to output the number of edges which if removed, makes the maximum frequency of a node value of both the resulting trees to be <= k. k is given and is <= n. The value of n goes upto 1e5.

I tried dfsing the frequency but soon realised I cant have the frequency of each subarray without storing them somewhere, which obviously wouldnt work due to both MLE and TLE. Please help!

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