When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

ologn_13's blog

By ologn_13, 11 years ago, In English

Hi all! I have been caught in this problem from past few hours....my thoughts are in following way:- first we'll do DFS and store number of nodes in the subtree rooted at every node..after this we would take all these numbers in sorted order and iterate from both sides(start and end) and print each pair till we reach middle..but this won't work if more than 2 subtree has same number of nodes.....please help here... or please discuss if there is any other simpler way than this..thanks in advance!! [CUT] EDIT: The problem is solved. From here it was nothing but to just take an "OR" of all combinations possible from each node with overall array of possible combinations.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
3 years ago, # |
Rev. 4   Vote: I like it 0 Vote: I do not like it

Any one please help with the apporaches of this problem. Problem My Submission Though I have solved the problem. But I have seen some interesting solutions which have used something similar to bitmasking which I am not able to understand. I would be thankful if any one could help me with that. demoralizer submission using bitmask

P.S. This problem doesn't have any editorial on so it will be helpful if this blog could be used for this problem's editorial.