algorithm - max size and no of equal subcubes >= given percentage -
i came across quesiton in code chef https://www.codechef.com/problems/cube.
there 2 cube cakes , chef want find similarity between them. each cube cake can represented cube of size n each cell of cube contains lowercase alphabet ('a'-'z'). similarity between 2 cube cakes ( of size n each ) defined maximum sized common sub-cube exists @ same position in both cube cakes. 2 sub-cubes said common if at-least p% of corresponding characters equal. need find size s of largest such sub-cube , number of common sub-cubes of size s in cube cake. input contains test case t (upto 40), n (the size of cube cake) 1 <= n <= 40. percentage p (0 100).
eg. 1 2 40 abcdefgh abcdefgh the answer 2 1 since both cubes identical , there 1 cube of length 2.
i p = 100 as
let dp[i][j][k] denote max size of similar cube ending @ i, j, k. hence dp[i][j][k] = min(dp[i-1][j-1][k-1], dp[i][j][k-1], dp[i][j-1][k], dp[i-1][j][k], dp[i-1][j-1][k], dp[i-1][j][k-1], dp[i][j-1][k-1]) + 1; but not handle when p < 100. looked this editorial. here have dealt case when p 100. in question has been given percentage (p) can less or equal 100. can please tell me how deal case when p < 100?
Comments
Post a Comment