Canada Day Contest 2021 - 0-1

View as PDF

Submit solution


Points: 20 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem types

You have a quantum computer containing two binary strings s and t, both of length n. Every second, x of the n bits on s are randomly chosen and flipped. Find the probability that after K seconds, s will become t.

Input Specification

The first line contains three integers, n, x, and K.

The next line contains the string s.

The last line contains the string t.

Output Specification

Find the probability of turning s into t. If the probability is AB, print AB1(mod109+7). It can be proven that the result is rational.

Constraints

0xn, 0K, 1n.

Subtask Score Constraints
1 10% n6, K100
2 12% n7, K700000
3 18% n10, K900000
4 12% n16, K109
5 48% n128, K109

Sample Input 1

Copy
4 1 2
0000
0000

Sample Output 1

Copy
250000002

Explanation For Sample 1

The probability is 14.

Sample Input 2

Copy
4 2 1
0000
0000

Sample Output 2

Copy
0

Sample Input 3

Copy
6 4 3
010000
100000

Sample Output 3

Copy
932444451

Sample Input 4

Copy
6 1 43
010000
011110

Sample Output 4

Copy
242545047

Sample Input 5

Copy
6 3 0
010000
010000

Sample Output 5

Copy
1

Sample Input 6

Copy
1 1 9
0
1

Sample Output 6

Copy
1

Comments

There are no comments at the moment.