Telepathy

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Brothers Flim and Flam are performing a trick they call "telepathy".

At the beginning, Discord, who is the host, generates two random binary strings aa and bb. Each string contains n=106n = 10^6 digits, and each digit is equal to zero or one equiprobably and independently of other digits. String aa is given to Flim, and string bb to Flam. Each of them sees only his own string, and doesn't know the string of his brother.

After that, each brother selects k=105k = 10^5 distinct positions in the string: not in his own, but in his brother's string that they do not know!

Finally, Discord looks at string aa from left to right, and writes down the digits from the positions selected by Flam. Then he looks at string bb from left to right and, under the previous line, writes down the digits from the positions selected by Flim. After that, the audience counts how many times a digit from aa turned out to be the same as a digit from bb written under it. To "prove" that telepathy works, more than two thirds of the pairs of digits have to turn out the same, that is, at least 66,66766\\,667 of them.

Help Flim and Flam to plan how to select positions in each other's strings knowing only their own string, so that they can "prove" that telepathy works.

Consider a small example.

  • To keep things short, let n=20n = 20 and k=5k = 5.
  • Let string aa be 00101011011110111001.
  • Let string bb be 11000111101000011010.
  • Flim sees string aa and selects positions 2,3,5,7,112, 3, 5, 7, 11 in string bb.
  • Flam sees string bb and selects positions 1,4,9,16,201, 4, 9, 16, 20 in string aa.
  • Discord writes down a_1=0a\_{1} = 0, a_4=0a\_{4} = 0, a_9=0a\_{9} = 0, a_16=1a\_{16} = 1, a_20=1a\_{20} = 1.
  • And under them, b_2=1b\_{2} = 1, b_3=0b\_{3} = 0, b_5=0b\_{5} = 0, b_7=1b\_{7} = 1, b_11=1b\_{11} = 1.
  • Out of five pairs, the digits are the same in each pair except the first (a_1=0a\_{1} = 0 but b_2=1b\_{2} = 1).
  • It means Flim and Flam achieved 4/54 / 5 equalities.
  • The portion of equalities is greater than 2/32 / 3, so the brothers "proved" that telepathy works!