← Questions
Weighted 01 and 10 subsequence pairs with wildcards
0
I was asked this
No reports yet. Sign in to say where you were asked it.
A status string holds '0', '1' and '!'. Every pair of positions i < j that reads 0 then 1 (a subsequence, not a substring) costs x, and every pair that reads 1 then 0 costs y. Replace each '!' with 0 or 1 to get the best total cost (the report asks for the extreme value; work out the minimum and say what changes for the maximum), modulo 10^9 + 7. Trying every replacement is exponential; find a linear or near-linear approach.
No official answer yet. Write yours on the right and run it.
Nothing published yet.
Sign in to submit your code; every attempt is kept here.
Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding
