# CODE 2021-Editorial

N-Special cards:
Quick Approach:
First of all you need to find uncovered positions in s (because rest of them will determine uniquely). If there is no parados in covered positions (a position should have more than one value), then the answer will be 0, otherwise it’s 26uncovered. To check this, you just need to check that no two consecutive matches in s have parados. So, for this purpose, you need to check if a prefix of t is equal to one of its suffixes in O(1). You can easily check this with prefix function (or Z function).

Ashsport
Quick Approach
Note that if r_i or b_i >= n, we need to collect tokens no matter what since those costs can’t be offset. So, we can assume that r_i, b_i <= n.
Let’s only buy tokens when we need them. Note that after buying a card, you will have either 0 red tokens or 0 blue tokens, so our dp state can be described by [mask][which one is zero][how many of the other] The dimensions of this dp table are 2^n * 2 * (n^2) (n^2 because the costs to buy cards is at most n).

Subham, Alisha and the tree