Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

OA problem help

Revision en1, by Aspergillus, 2024-07-20 13:07:19

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!

Tags graph, tree, frequency array, help

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Aspergillus 2024-07-20 13:07:19 602 Initial revision (published)