When I'm taking part in Educational Codeforces Round 87,I come up with a random solution.
But I didn't think it can pass.(In fact I'm wrong and the solution has more than 99.99% possibility to pass)
And I think for a long time to find a non-random solution without getting good ideas
Can somebody solve this problem?