How this solution works ?
this is a solution for problem H from last contest , can anyone explain to me how this solution works ?
Codeforces Round 946 Solution Discussion