tejas2's blog

By tejas2, history, 18 months ago, In English

Following is my solution for 977E - Cyclic Components (Finding number of cyclic connected components in a graph) :- My Solution : 207324313. Can anyone please tell why am I getting MLE?

  • Vote: I like it
  • +1
  • Vote: I do not like it

| Write comment?
»
18 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Pass your graph by reference in the dfs function.

»
18 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You gotta pass by referance or as my personal preferance, declare variables globally. Not only do functions get easier to manage, also you don't have to deal with pointers and referances.

»
18 months ago, # |
  Vote: I like it +4 Vote: I do not like it

pass by reference the adj vector in your dfs function.

Hope you successfully solved it

»
18 months ago, # |
  Vote: I like it +3 Vote: I do not like it

Passing by reference / declaring globally worked. Thanks Everyone