In Chinese CSP-S1 today morning, there was a question to use "The Method of Four Russians" to solve RMQ problem. Can anyone do me a favor to teach me what it is? Thank you!

# | User | Rating |
---|---|---|

1 | tourist | 3707 |

2 | Benq | 3672 |

3 | Radewoosh | 3627 |

4 | ksun48 | 3547 |

5 | Miracle03 | 3480 |

6 | ecnerwala | 3400 |

7 | peehs_moorhsum | 3384 |

8 | maroonrk | 3361 |

9 | sunset | 3338 |

10 | Um_nik | 3320 |

# | User | Contrib. |
---|---|---|

1 | 1-gon | 209 |

2 | Um_nik | 196 |

3 | YouKn0wWho | 192 |

4 | Errichto | 182 |

5 | awoo | 181 |

6 | sus | 180 |

7 | tourist | 175 |

8 | -is-this-fft- | 171 |

8 | SecondThread | 171 |

10 | Radewoosh | 170 |

In Chinese CSP-S1 today morning, there was a question to use "The Method of Four Russians" to solve RMQ problem. Can anyone do me a favor to teach me what it is? Thank you!

↑

↓

Codeforces (c) Copyright 2010-2021 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Oct/20/2021 05:56:16 (h1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|

You don't need to learn it now.CCF just had water in it's mind.Don't pay too much attention on that F*** problem

Haha. But the contest is good, I think. I've found that even in Codeforces this Russian website there are few explanations about TMoFR.

You can see that here. (Maybe unfriendly to people unfamiliar to Chinese

And CCF says this algorithm is $$$\Theta(N+Q)$$$ , but OI-wiki says that it should be $$$\Theta(N\log\log N+Q)$$$ ! I think CCF is wrong.

UPD:I didn't see clearly. It should be $$$\Theta(N+Q)$$$That's a $$$+1/-1$$$ RMQ problem because the depths of adjacent nodes in the euler sequence only can be differ by one. So this algorithm is $$$\Theta (N+Q)$$$.

Oh yes I didn't see that clearly.

Sorry!

Great, is this blog from you? That's nice.

Nope,but OI-wiki.

In a word, I think it's quite not proper to put an Russian alorgithm in a Chinese exam :D

Maybe "The Method of some numbers of Chinese" should be put in.

One of the things you DON'T need to know.

Sure. I even don't know what the Cartesian tree is about.

The Method of Four Russians is a very general technnique, and not just limited to the RMQ. It roughly has to do with "precomputing" the answers for small parts of the problems, and use some other more general structure for the larger parts of the problem.

For instance, in RMQ with The Method of Four Russians, you essentially try to make a sparse table on the range-minima of blocks of small size, and precompute the answers for all small blocks. However, just doing a brute force doesn't work for all small blocks, so rather than solving this for the original problem, we try to find the position of the minimum in equivalence classes of small blocks (which are $$$C_s$$$ in number, where $$$s$$$ is the size of blocks, and $$$C_s$$$ is the $$$s$$$-th Catalan number), which are few in number, and recognize which block each small array corresponds to.

For a more detailed explanation, you can consider reading https://web.stanford.edu/class/cs166/lectures/01/Small01.pdf