#P7047. 「MCOI-03」数据
「MCOI-03」数据
Description
Below are some common definitions. If you are already familiar with them, you may skip this part.
A 01 string is a string that contains only the two characters 0 and 1. It is also allowed to contain only one of them.
Taking a consecutive segment of a string is called a substring. It is easy to see that a string of length has substrings of length .
The mean value of a set of real numbers is , that is, the sum of all elements divided by the number of elements.
Based on this, the variance of is , that is, the sum of squared differences between each element and the mean, divided by the number of elements.
The binary value of a 01 string of length is , where is the digit on the -th character of from left to right.
In this problem, we define the following:
A piece of data is a 01 string of length .
The "toxic level" of a piece of data is defined as the variance of the binary values of all its substrings of length .
Now, you are given the first characters of a piece of data. You need to find the last characters such that the "toxic level" of the whole data is minimized. If there are multiple solutions, output them sorted by the binary value of the substring formed by these last characters, from small to large.
Input Format
The input contains one line, a 01 string of length , representing the first characters of a piece of data.
Output Format
Output several lines. Each line contains a 01 string of length , representing the last characters of a piece of data with minimum "toxic level". Output them sorted by their binary values in increasing order.
10
10
Hint
Explanation for Sample 1
In this example, . There are four pieces of data that satisfy the requirement: 1000, 1001, 1010, 1011.
1010 has three substrings of length : 10, 01, 10. Their binary values are . The mean of is , and the variance is . Therefore, the "toxic level" of 1010 is .
You can compute that the "toxic levels" of these four pieces of data are , respectively. Among them, 1010 is the only one with the minimum "toxic level", so the program outputs its last characters 10.
Constraints and Notes
It is guaranteed that all testdata are generated randomly. For each bit of the 01 string, the probability of being 1 is , and different bits are independent.
This problem does not use bundled tests. It is scored by test points. Test point is worth point, and each other test point is worth points.
For each test point, the size of is given in the table below:
| Test Point ID | ||||
|---|---|---|---|---|
| Test Point ID | ||||
Note: In C++, you can use the -bit integer __int128.
Translated by ChatGPT 5
京公网安备 11011102002149号