I need help with z-most.
Here's my submission.
http://www.z-trening.com/submit.php?subm_stat=1&submit=7100273131
I have no idea why it runs so slow!
I tried this on my computer and it takes a bit more than 10s to execute.
100 16
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
Can you help me?
My solution implements dynamic programming.
I use bitmasks. 1 represents person who needs to go over the bridge while 0 represents person who has already crossed it. Solution is d[2^m - 1]. Any ideas how to speed it up? Thanks.
P.S. I also tried implementing bit hacks to find index of last 1 in binary number in O(1) complexity, but it doesn't show significant improvement. Help! :(
Here's my submission.
http://www.z-trening.com/submit.php?subm_stat=1&submit=7100273131
I have no idea why it runs so slow!
I tried this on my computer and it takes a bit more than 10s to execute.
100 16
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
1 1
Can you help me?
My solution implements dynamic programming.
I use bitmasks. 1 represents person who needs to go over the bridge while 0 represents person who has already crossed it. Solution is d[2^m - 1]. Any ideas how to speed it up? Thanks.
P.S. I also tried implementing bit hacks to find index of last 1 in binary number in O(1) complexity, but it doesn't show significant improvement. Help! :(