WA in Chefword

Here’s a link to my solution : http://www.codechef.com/viewsolution/5440351
I don’t understand where i am going wrong …is it the double or some other precision thing i am missing ??

I’m not a C/C++ guru, but what is ans.a[i][j]=double(i==j); doing?

See my test case on ideone - http://ideone.com/pgtqzj

actually u are not giving a valid input …
the condition clearly states Sum of ai,1+…ai,n = 1
but the sum of all probabilities in the first row of your testcase is 3.
ans.a[i][j]=double(i==j); is for making an identity matrix.

1 Like

Ok I thought so (double(i==j)), hopefully it’s better now, those two ones was an error… Still printing 0.75, I’d expect 0.25, hopefully input is ok now…

But why 0.25 : two cases arise here:

  1. a -> a -> a =0.5 x 0.5 = 0.25
  2. a->b->a =0.5 x 1=0.5
    total 0.75…right??
1 Like

Of course, my bad, I’ll get back with better test case :wink:

Ok, now - http://ideone.com/pgtqzj it was not so easy…

2 Likes

@betlista… thanka a lot… it was the hashing problem…it was really frustrating for a while…