I can' find c++ code of pattern magic problem

i am not able to solve the pattern magic problem and I am also not able to find it’s c++ solution in editorial. kindly help.

refer to this code

i have commented each steps so that you can understand properly

i hope this helps
if you have any doubt feel free to ask

runguard: warning: timelimit exceeded (wall time): aborting command runguard: warning: command terminated with signal 15… it is showing this error

try again code is correct and tested also

if you have still doubt and it is not working let me know

try now
is it working?

if not then kindly drop a mail at [email protected]

@arugarg
is your code submitted??