Блог пользователя rsampaths16

Автор rsampaths16, история, 10 лет назад, По-английски

About a month ago in Augest-Long-Challenge[2016] a question — "Funny — Genome" was asked in CodeChef. Although no Official Editorial was released for it , "wodahs_cc" suggested that we need to use "Four Russian Method" to solve for the problem in the forum. I've searched the Internet and also gone through the Video for it, but I could not find a proper implementation to it, So I've Implemented it with my own understanding of the algorithm but still got "Time-Limit-Exceeded" error for some test cases. I don't know what I did wrong. I request you people of Code-Forces community to kindly provide an Implementation for the Four-Russian-Method. I thank you all in advance.

P.S : A Link to my Implementation.

  • Проголосовать: нравится
  • +10
  • Проголосовать: не нравится

»
10 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by rsampaths16 (previous revision, new revision, compare).

»
10 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

As far as speeding up boolean matrix multiplication is concerned, I feel using bitset is much more convenient and easier to write. According to me "method of four Russians" gives a speed upto (logn), but in most cases n <= 1000, when matrices are being considered. In such case, log(n) ~ 32, which is also the speed up due to using bitset.

If you implement the bitset, yourself using long long, you may also end up getting a speedup upto 64 times. I think in most cases, bitset suffices.

You can refer to my implementation using (self-written) bitset Code

Using the STL bitset, here is another small clean implementation Code 2