http://web.mit.edu/~mip/www/probs.html
[12] Sorting by reversals (ONI'04)
You are given an array A[1..N]. Your goal is to sort A by the
following type of operation: pick some indices i,j and reverse the
subarray A[i..j]. Such an operation costs j-i+1, i.e. the length of
the portion which is rever
Nik wrote:
> Hi,
> This is regarding the problem 253 (painting cube ) on
> uva.http://acm.uva.es/p/v2/253.html
> I have got this problem accepted from the below code. I have removed
> some variables and other things
> to make sure this problem doesn't get accepted by copy paste method.
>
>
why don't you try a brute force technique through a simple program,to
see what it's gonna happen.You have a 4 nested loop(O(n^4))
e.g
number x=abcd
for(a=1t o 9) do
{for(b=1 to 9)do
{for(c=1 to 9)do
{for (d=1 to 9)do
{ y=1000*a+100*b+10*c+d;
if prime(y) and prime(permute(z)
i believe that your proble is somewhat closely related with Longest
common subsequence(which can be solved by DP)between two strings,albeit
the problem that you have more than two strings intuitively for me
means that as if you have two strings the complexity is O(nm) because
you fill in an 2 dime