ndpqx's blog

By ndpqx, history, 4 weeks ago, In English

Can someone help me in this problem please? I debugged it for a while but I can't understand why my code was being MLE :(( Thank you so much. P/S: Sorry for my bad English :( Sub: https://codeforces.com/contest/769/submission/93610574

  • Vote: I like it
  • -6
  • Vote: I do not like it

4 weeks ago, # |
  Vote: I like it 0 Vote: I do not like it

Instead of doing $$$ok[ check.fi ][ check.se ] = 1;$$$ after you pop it from the queue, do it while pushing into the queue. Right now your queue can hold many duplicates of some cell $$$(x,y)$$$. When you push the first instance of $$$(x,y)$$$, you should immediately change the ok status to 1 so that no duplicates of $$$(x,y)$$$ enters the queue.