Can anyone please share a possible solution to this problem — called knin (you can search for it in tasks, it is one of the bottom, maybe you need to zoom out to see it)
Note that the memory limit is unusually tight, you cant even keep a matrix to the problem`s board
EDIT: why did I get some downvotes? Maybe because people thought that I was trying to cheat? That is not the case! The official contest where this problem was has ended, now this problem is in the practice section (you can check this fact by reading the link). If people downvoted me for other reason I would like to know why and possibly improve! : )
Thanks a lot in advance!