The problem in question is [Hamiltonian wall](https://mirror.codeforces.com/problemset/problem/1766/C) and I wrote a solution to this that works, but I suspect that it is the wrong solution. My solution is [this](https://mirror.codeforces.com/contest/1766/submission/198643038). The reason I suspect that my solution is incorrect is because, if in the DFS function I change the order of the two loops, I get the wrong answer(when that should not be happening). I would really appreciate if anybody could point out what is wrong with DFS function.↵
↵
Thanks, if you need any clarification regarding some of the terms in my template or regarding my approach, feel free to comment down below↵
EDIT: I removed the lengthy template
↵
Thanks, if you need any clarification regarding some of the terms in my template or regarding my approach, feel free to comment down below↵
EDIT: I removed the lengthy template