Codeforces functionality may be limited from June 18, 19:00 (UTC) to June 19, 3:00 AM (UTC) due to technical maintenance. Polygon will work as usual. ×

tejas2's blog

By tejas2, history, 13 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?
»
13 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Pass your graph by reference in the dfs function.

»
13 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.

»
13 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

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

Passing by reference / declaring globally worked. Thanks Everyone