This is the original version of problem ,during the contest I tried to solve it using some combinatorics logic but i can't and for this version of problem we can just iterate over all possible PIN codes because constraints are small, yes i didn't able to get this logic during the contest, but i am curious to know the approach to solve this question if PIN size will be of 10 digits.
I was curious about this too (and I am skeptical to think this is the only better way), but we can do pins of slightly larger size using bitmask dp:
Let dp[i][bm] = the # of "good" strings of length i where bm = the digits that are used (a 10 bit number where 1 in a bit position indicates that digit was used, 0 otherwise). Then we can see that the transitions are:
// we decide to use this digit in position i, and the digit is of type 'o' or '?'
dp[i + 1][bm | (1 << digit)] += dp[i][bm]
Then we use the string they gave us to precompute the "good" bitmasks (aka, if the string they gave us says that we need a digit in our string, then we only look at bitmasks with this bit on). This gives us a runtime of doing digits * 2^10 * 10 operations, which should be able to handle 10 digits.
https://atcoder.jp/contests/abc201/submissions/22653905 is my submission for this (using this idea), although I am willing to hear other (probably better) solutions