Mkswll's blog

By Mkswll, 9 months ago, In English

I actually thought I had a quite good understanding of std::set and std::multiset until D of the last Div. 2 contest taught me a lesson (you can tell from my submissions on D). So I decided to write this blog to prevent other people from making similar mistakes when overloading the < operator in sets (if these are just common sense then it's probably just my skill issue). If there exists a blog that talks about similar things please do inform me.

Try to think of the output for each of the following codes.

1) (with std::set)

Code 1
Explanation 1

2) (with std::multiset)

Code 2
Explanation 2

3) (with std::multiset, very similar to (2))

Code 3
Explanation 3

These tips are really about the same core idea, but I decided to write three tips because I actually made all these three mistakes (which made my debugging life despairing). Hope these are helpful to you!

(PS: I love how the name of the problem is literally "More Wrong" xd)

Full text and comments »

  • Vote: I like it
  • +78
  • Vote: I do not like it