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?
# | User | Rating |
---|---|---|
1 | Benq | 3783 |
2 | jiangly | 3666 |
3 | tourist | 3611 |
4 | Um_nik | 3536 |
5 | inaFSTream | 3477 |
6 | fantasy | 3468 |
7 | maroonrk | 3464 |
8 | QAQAutoMaton | 3428 |
9 | ecnerwala | 3427 |
10 | Ormlis | 3396 |
# | User | Contrib. |
---|---|---|
1 | Um_nik | 184 |
2 | adamant | 178 |
3 | awoo | 177 |
4 | nor | 169 |
5 | maroonrk | 165 |
6 | -is-this-fft- | 164 |
7 | antontrygubO_o | 152 |
8 | ko_osaga | 151 |
9 | dario2994 | 150 |
10 | SecondThread | 149 |
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?
Name |
---|
Pass your graph by reference in the dfs function.
In the dfs function you also have to pass "vector adj" by reference. If you don't pass any data structure by reference then a copy of that data structure is passed in the function, not the original data structure. Thus you are getting MLE.
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.
I would suggest u to use lamda function
pass by reference the adj vector in your dfs function.
Hope you successfully solved it
Passing by reference / declaring globally worked. Thanks Everyone