salt_n_ice's blog

By salt_n_ice, 6 weeks ago, In English

Link
I tried solving this using the ordered_set gnu pbds
I did dfs along with using swap and move methods for merging the sets of each node's children. The time complexity should be nlogn but why is it giving TLE on test 15?

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

»
6 weeks ago, # |
  Vote: I like it -16 Vote: I do not like it

Don't act like you really know how move works like, it's much more difficult than one can imagine. Read this.

  • »
    »
    6 weeks ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Okay move function doesn't work here but is there any way to make this approach work?

    • »
      »
      »
      6 weeks ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Just don't call move explicitly, use return ret;.

»
6 weeks ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

x.swap(ret). I also believe that ordered_set is not the intended solution anyway.

and move is useless here