Binary search and other "halving" methods

As a certain legendary grandmaster once said (paraphrased), if you know obscure techniques and are not red yet, go and learn binary search. The main aim of this tutorial is to collect and explain some ideas that are related to binary search, and collect some great tutorials/blogs/comments that explain related things. I haven’t found a comprehensive tutorial for binary search that also explains some intuition about how to get your own implementation right with invariants, as well as some language features for binary search, so I felt like I should write something that covers most of what I know about binary search. ...

November 7, 2021 · 27 min · 5542 words · nor

GCC Optimization Pragmas

Introduction A while ago ToxicPie9 and I made and posted this meme: To my surprise, many people are quite confused about it. In fact, I realized there are a lot of misconceptions about pragmas. Most C++ users on Codeforces put a few lines of pragmas at the start of every submission. However, I believe many of them don’t fully understand what they’re doing or how pragmas work; the only thing people seem to think is that “add pragmas -> code go brr”. ...

October 26, 2021 · 12 min · 2453 words · nor

Traversing the complement graph in linear/near-linear time in multiple ways

In this post, I will focus on the following problem: 920E. More generally, we will look at how to do efficiently traverse the complement graph of a given graph in both dfs and bfs orders. In particular, the bfs order also allows us to find a shortest-path tree of the complement graph. This is my first post, so please let me know of any errors/typos that might have crept in. Note 1: I will present the algorithms in the order I came up with them, so it might not be the most clean presentation, but I hope that it might give some insight into how to come up with new ideas in graphs. Note that I don’t claim to be the first person to come up with these ideas (especially the naive algorithm, which is identical to the solution in the editorial), but I haven’t seen any of these implementation tricks being used in any implementation before. Resources pointing to similar ideas/implementations are welcome! ...

August 12, 2021 · 8 min · 1526 words · nor
>