[Solution] Problem with Random Tests Codeforces Solution
You are given a string consisting of characters. Each character of is either 0 or 1.
A substring of is a contiguous subsequence of its characters.
You have to choose two substrings of (possibly intersecting, possibly the same, possibly non-intersecting — just any two substrings). After choosing them, you calculate the value of the chosen pair of substrings as follows:
- let be the first substring, be the second chosen substring, and be the integer such that is its binary representation (for example, if is 11010, );
- the value is the bitwise OR of and .
Calculate the maximum possible value you can get, and print it in binary representation without leading zeroes.
The first line contains one integer — the number of characters in .
The second line contains itself, consisting of exactly characters 0 and/or 1.
All non-example tests in this problem are generated randomly: every character of is chosen independently of other characters; for each character, the probability of it being 1 is exactly .
This problem has exactly tests. Tests from to are the examples; tests from to are generated randomly. In tests from to , ; in tests from to , ; in tests from to , .
Hacks are forbidden in this problem.
Print the maximum possible value you can get in binary representation without leading zeroes.
In the first example, you can choose the substrings 11010 and 101. , , their bitwise OR is , and the binary representation of is 11111.
In the second example, you can choose the substrings 1110010 and 11100.
No comments:
Post a Comment