Please tell me the proof of the solution ARRTWIST. After searching online for hints, I found none. I only found solution, so I saw it hoping that I would get hint on implementation , etc. But solution is one liner. Can someone give me proof or atleast an intuition about that?
https://www.spoj.com/problems/ARRTWIST/