Why do I get MLE with bfs?

Правка en1, от Vasillia, 2024-04-09 11:12:12

I don't understand why I get MLE on this problem https://mirror.codeforces.com/contest/1955/problem/G when using bfs.

Here is the code: https://mirror.codeforces.com/contest/1955/submission/255789320.

I was able to solve it later with dfs, but I'm still confused why this bfs that i wrote does not work. Obviously the problem is in this queue Q, but after every bfs call it should be empty again, so size of Q is always <= 100 * 100, which should not get out of memory limit. I would appreciate if someone will help me understand this.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский Vasillia 2024-04-09 11:12:12 560 Initial revision (published)