When i submitted my solution, the judge throws me Runtime Error on test 8, more specifically with this test:
10 10
.........*
.........*
........**
.........*
.........*
.........*
.........*
.........*
.........*
.........*
But i ran the program with this test in my computer and it works correctly and the output is correct:
YES
3 10
In test function third loop change
i < p[i].size()
toi < p[Y].size()
.It will TLE anyway.
Very thanks!