https://codeforces.com/contest/1141/problem/G

题解: