Need help in optimization

Revision en1, by Jack_Daniels_, 2024-12-07 19:15:58

I have a problem: given a tree on N vertices, I need to answer requests with 2 types: 1)Delete I-th edge if it's in the graph (or vice versa). 2)Find a maximum matching in a component including vertex X. I have a solution: dfs with DP on tree to count maximum matching on each request, but N and Q <= 1e5 and I've TL. How I can improve this?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Jack_Daniels_ 2024-12-07 20:34:04 153 Tiny change: '2 types:\n1)Delete' -> '2 types:\n\n1)Delete'
en1 English Jack_Daniels_ 2024-12-07 19:15:58 373 Initial revision for English translation
ru1 Russian Jack_Daniels_ 2024-12-07 18:16:50 373 Первая редакция (опубликовано)