I've been debugging this for a while and I still can't tell why it exceeds the memory limit.
Can somebody help me?
Submission: 5723491
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
I've been debugging this for a while and I still can't tell why it exceeds the memory limit.
Can somebody help me?
Submission: 5723491
Name |
---|
Turns out using
ArrayDeque
instead ofLinkedList
makes the problem pass.I have the same problem, what can I do? Submission : 5724820
I think it's because you do recursion and the stack can grow up to 4kk (essentially the longest path) keeping the state of all intermediates. You can generate that case easily.
By the way, your code gets accepted using MS C++ ( http://mirror.codeforces.com/contest/382/submission/5726207 ). I had the same problem, and got accepted with gnu compiler only with dfs on std::stack.
Some codes with the same recursion passed, but they were close to memory limit,
I just submitted the code with MS C++ and it used much lower memory!!
I have the same problem MLE:
Submissions:
(recursive dfs) 5735956
(iterative bfs) 5741952
(iterative bfs) 5746973
I first started with recursive dfs with excessive usage of
new
(1st submission), so I kinda removed it, then found the longest path will overflow the stack. So, I went to iterative bfs, while storing the final nodes, and following back their path (2nd submission), it didn't go well. So, I removed all that and calculated the distances as I go through the BFS (3rd submission), and now I have no idea, what might have caused the MLE, given that I seen Java solutions similar to what I do. Any help?What if you change int[][] grid to char[][] grid or at least short[][]
Please Check my 1st comment :)
It worked, thanks! I better learn to watch out next time.