https://www.spoj.com/problems/ADAMATCH/
How to solve this problem?
# | User | Rating |
---|---|---|
1 | jiangly | 3640 |
2 | Benq | 3593 |
3 | tourist | 3572 |
4 | orzdevinwang | 3561 |
5 | cnnfls_csy | 3539 |
6 | ecnerwala | 3534 |
7 | Radewoosh | 3532 |
8 | gyh20 | 3447 |
9 | Rebelz | 3409 |
10 | Geothermal | 3408 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 173 |
2 | adamant | 164 |
3 | awoo | 161 |
4 | TheScrasse | 160 |
5 | nor | 159 |
6 | maroonrk | 156 |
7 | SecondThread | 152 |
8 | pajenegod | 146 |
9 | BledDest | 144 |
10 | Um_nik | 143 |
https://www.spoj.com/problems/ADAMATCH/
How to solve this problem?
Name |
---|
This problem can be solved in a similar way as MAXMATCH.
You can first find maximum matching of the two strings by keeping s fixed and varying r. To achieve that you can construct polynomial for each of the different character, by raising x to the powers of indexes in
s
and to negative of powers of index inr
. For example considers = ATCAAA
r = ACAA
Now for character
A
, and s you will construct polynomial x0 + x3 + x4 + x5And for character
A
, and r you will construct x0 + x - 2 + x - 3.Now when you multiply them, the coefficient of xk will represent number of matching indexes for
A
in kth shift.You can just sum that over all four characters and answer will
res.size() - maximum_matching
But, how we will multiply them? FFT multiplies polynomials with non-zero powers of x.
Can you please explain why r contains the negative of powers of index?