A. Mathematical Addition
Solution:
Obviously, when $x=u^2,\ y=-v^2$, the conditions are met.
Code:
Java
![](https://codeforces.org/s/44585/images/codeforces-telegram-square.png)
C++
![](https://codeforces.org/s/44585/images/codeforces-telegram-square.png)
B. Coloring Rectangles
Solution:
Divide the total area by 3 is the answer. If it is not divisible by 3, add one. Because if the remainder is 2, a blue block is naturally needed. If the remainder is 1, then it needs to be joined with the area of 3 to form a block of area 4, and a blue block needs to be added.
Code:
Java
![](https://codeforces.org/s/44585/images/codeforces-telegram-square.png)
C++
![](https://codeforces.org/s/44585/images/codeforces-telegram-square.png)
C. Two Arrays
Solution:
Obviously, consider the number of occurrences of each number from small to large, and then increase by 1 as less as possible.
Code:
Java
![](https://codeforces.org/s/44585/images/codeforces-telegram-square.png)
C++
![](https://codeforces.org/s/44585/images/codeforces-telegram-square.png)
D. Guess the Permutation
It is a nice problem for binary search. The cleverness is that for a certain query result, if the x of $\frac {x \cdot (x-1)} 2=result$ has an integer solution, then it's high possiblity that the query interval will not cross j.
![](https://zh.xloypaypa.pub/content/images/2021/11/image-12.png)
E. Game with Stones
The segment tree + binary search I used here. Seems official tutorial have a more clever solution. But I can also get AC, but it is easier to TLE.
![](https://codeforces.org/s/44585/android-icon-192x192.png)