# | User | Rating |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
# | User | Contrib. |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Name |
---|
I guess the problem is array
jaroori
which has size up toN
in your solution, but it's clearly contains some info about edges, so should be up toM
(orN * N
asfrom
andto
)Thanks for pointing it out ! i believe it should give me segmentation fault rather than MLE !
Well, technically it's undefined behavior, so anything could happen =)
Also if you enable some compiler options (like address sanitzer) it should catch this kind of issue. Check this post http://codeforces.me/blog/entry/15547. It could help to catch this kind of bugs locally (if you actually do proper testing locally, if not then start doing ;)).
If you want to understand what exactly going on in your case you can take a look at disassembly: https://godbolt.org/g/sYE6qJ
So it seems that layout for data is
jaroori
and thenparent
. So potentially what could happen that you will override some of theparent
's value and create a loop, e.g.parent[0] = 1
,parent[1] = 0
and then you'll have unbounded recursion. Stack size limit for G++ is 256MB (according to http://codeforces.me/blog/entry/79).So you have some memory allocated besides that + you probably almost hit stack size limit and got MLE before you've got RTE due to stack overflow.
Could be something else, but you can investigate further on your own.