Блог пользователя islam-al-aarag

Автор islam-al-aarag, 11 лет назад, По-английски

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

  • Проголосовать: нравится
  • +3
  • Проголосовать: не нравится

»
11 лет назад, # |
  Проголосовать: нравится +3 Проголосовать: не нравится

Turns out using ArrayDeque instead of LinkedList makes the problem pass.

»
11 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I have the same problem, what can I do? Submission : 5724820

»
11 лет назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

I have the same problem MLE:

Submissions:

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?