## A. Binary Decimal

### Solution:

Obviously, we only need to check every digit. For each digit, as many as its digit, it needs to be composed of as many numbers. For example, if the tens place of 321 is 2, it needs to be composed of two numbers.

### Code:

Java

C++

## B. Putting Plates

### Solution:

Just simulation. We scan each point from left to right and from top to bottom. As long as the point is on the boundary and the surrounding area of the point is not occupied, we will occupy the point.

### Code:

Java

C++

## C. Pursuit

### Solution:

Just simulation. Because every time a stage is added, the player gets 100 points and Ilya gets 0 points. Therefore, we only need to maintain the scores after adding a stage.

For players, we use a priority queue. Because for each additional stage, the stage with the lowest score in the priority queue may be removed. Therefore, we only need to maintain the length of the priority queue based on the total number of stages.

For Ilya, we sort the games that Ilya is already completed. As the number of stages increases, Ilay will gradually lose points from the stages with lower scores.

Keep increasing the number of stages until the player score is higher than Ilya.

### Code:

Java

C++

## D. Secret Santa

### Solution:

First of all, as many different numbers appear in b, there will be as many people who can be fulfilled. So the question now is how to handle the rest of the people.

Then there is only one possibility for the remaining person to have a problem: b[i]=i. And the person who will receive gift from i must be sent gift by someone else.

Suppose there are two people i and j, at the beginning b[i] and b[j]=x, and finally b[i]=i, b[j]=x. So we only need to exchange the gift-giving goals of two people, that is, b[i]=x, b[j]=i.

Therefore, we first ignore the condition that we cannot give ourselves gifts, and we can allocate them in order under the condition of ensuring that everyone's wishes are fulfilled as much as possible.

After allocating, check the person who giving gifts to themselves. For such a person, we can find the person who gives gifts to the same target and exchange with him.

### Code:

Java

C++

## E. Minimax

### Solution:

Obviously, if a letter appears only once, then f(t)=0, we only need to put this letter at the beginning. For example, aabbz, then zaabb.

It is not difficult to find, unless a certain letter appears only once. Otherwise, f(t)>0. For example, x???x?, f(t)=1 when k=5.

Then, if the number of occurrences of a certain letter is less than around half of the total, the following string can be constructed: xxyxyxyxyxy... so f(t)=1.

Otherwise, if there are two letters, we construct xyyyyyxxxxx... so that f(t)=1.

Otherwise we construct xyxxxxxxxxzabcd. Such f(t)=1.

Just tons of if else.

### Code:

Java

C++