Problem 2977 · Hard

Minimum Cost to Convert String II

Run Floyd-Warshall over every distinct rule string, then let a prefix DP choose where to cut source and target into convertible pieces.

Open the interactive visualisation