Hi all. No editorials are available for both the problems and I did not understand a solution code that is present on GitHub https://github.com/pkkj/ACM-ICPC-OJ-Code/blob/master/ICPC.Regional/2006.Yokohama/3621.cpp. It would be helpful if someone can explain it and provide link for suitable resources. Problem link https://www.spoj.com/problems/GSMATRIX/ , https://www.spoj.com/problems/YOKOF/. Happy coding.