Блог пользователя 00x3f00f3x

Автор 00x3f00f3x, история, 4 года назад, По-английски

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.net/contest/769/submission/93610574

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

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

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.