Writing C++ like Python: tricks Python doesn't want you to know

This post was originally written on Codeforces; relevant discussion can be found here. People often say C++ is much more cumbersome to write than any sane language should be, but I think that is mainly due to lack of knowledge about how to write modern C++ code. Here’s how you can write code more smartly and succinctly in C++(20): Negative indexing with end Have you ever found yourself using a vector like a stack just because you have to also access the last few positions, or writing a sliding window code using a deque (where the size might be variable, but you want to access an element at some offset from the end)?...

January 11, 2023 · 14 min · 2789 words · nor

A comprehensive guide to permutations for beginners

This post was originally written on Codeforces, relevant discussion can be found here. This post is intended to be an introduction to permutations for beginners, as there seem to be no resources other than cryptic (for beginners) editorials that talk about some cycles/composition, and people unfamiliar with permutations are left wondering what those things are. We’ll break the post into three major parts based on how we most commonly look at permutations....

January 9, 2023 · 33 min · 6854 words · nor

Insights from testing and preparing contests, and why problemsetting trends need to change

This post was originally written on Codeforces; relevant discussion can be found here. I’ve been involved with testing a lot of Codeforces contests and coordinating contests for my uni, and have seen various kinds of issues crop up. However, I was able to come up with a stable system for my uni contests that helped make the experience as educational and error-free as possible, and I have found the lack of some of those things to be the main reason behind issues faced by Codeforces contests....

January 6, 2023 · 16 min · 3258 words · nor

Greedoids: a formal way to look at families of greedily-solvable problems

This post was originally written on Codeforces; relevant discussion can be found here. Disclaimer: This is not an introduction to greedy algorithms. Rather, it is only a way to formalize and internalize certain patterns that crop up while solving problems that can be solved using a greedy algorithm. Note for beginners: If you’re uncomfortable with proving the correctness of greedy algorithms, I would refer you to this tutorial that describes two common ways of proving correctness — “greedy stays ahead” and “exchange arguments”....

January 4, 2023 · 35 min · 7373 words · nor

Interesting ideas/techniques to write about, or just new stuff in general?

This post was originally written on Codeforces; relevant discussion can be found here. Recently, I retired from competitive programming completely, and I found myself wondering about what I’ll do with all the competitive-programming-specific knowledge I have gained over the years. For quite some time, I’ve been thinking of giving back to the community by writing about some obscure topics that not a lot of people know about but are super interesting....

December 31, 2022 · 2 min · 278 words · nor

On using C on Codeforces (and some compiler update requests)

This post was originally written on Codeforces; relevant discussion can be found here. This post was initially meant to request updates to the C compiler on Codeforces (given the large number of posts complaining about “mysterious” issues in their submissions in C). While writing it, I realized that the chances of the said updates would be higher if I mentioned a few reasons why people would like to code in C instead of C++ (some of the reasons are not completely serious, as should be evident from the context)....

December 31, 2022 · 9 min · 1804 words · nor

On using vim, make and gdb for online (CF, AtCoder) and onsite (ICPC, IOI) contests

This post was originally written on Codeforces; relevant discussion can be found here. Since someone recently asked me about my competitive programming setup, and I like tinkering with my setup to make it as useful and minimal as possible, I thought I should share my setup that I’ve used for the past few years and a modified version that I’ve used at onsite ICPC contests. I’ve also talked to a few people who went to IOI and had a similar setup, and I’m fairly confident that at least some people will be able to successfully use this without having to worry too much about the details, like I did....

December 31, 2022 · 14 min · 2927 words · nor

Probability 101, the intuition behind martingales and solving problems with them

This post was originally written on Codeforces; relevant discussion can be found here. Recently someone asked me to explain how to solve a couple of problems which went like this: “Find the expected time before XYZ happens”. Note that here the time to completion is a random variable, and in probability theory, such random variables are called “stopping times” for obvious reasons. It turned out that these problems were solvable using something called martingales which are random processes with nice invariants and a ton of properties....

December 31, 2022 · 34 min · 7042 words · nor

Catalan Numbers and Generating Uniform Balanced Bracket Sequences

This was written jointly by errorgorn and me and published on errorgorn’s blog, and the original post is here. Hi everyone! Today nor sir and I would like to talk about generating uniform bracket sequences. Over the past few years when preparing test cases, I have had to generate a uniform bracket sequence a few times. Unfortunately I could not figure out how, so I would like to write a post about this now....

May 27, 2022 · 24 min · 4998 words · nor

InterviewForces Contest #1 (Div. 7) Editorial with Behind The Scenes and Bonus Problems

We ended up making a meme contest, here’s the editorial for the contest. The original editorial is here. Thank you for participating in this round! We hope you found the problems interesting and/or funny. Special thanks to dorijanlendvaj for helping with Polygon related issues. Preparing good tests for certain problems was in fact a good problem in itself (in fact, sometimes they were hard enough for usual CF rounds), and we will mention these problems for the interested reader....

May 25, 2022 · 5 min · 1019 words · nor
>