pllk's blog

By pllk, history, 8 months ago, In English,

Competitive Programmer's Handbook is a new book on competitive programming, written by me. The book is still in progress but almost ready, and I decided to release it now for a wider audience.

You can download the book here:

https://cses.fi/book.html

The book consists of 30 chapters and is divided into three parts. The first part discusses basic topics such as programming style, data structures and algorithm design. The second part deals with graph algorithms, and the third part introduces some more advanced techniques.

The book assumes that the reader knows the basics of programming, but no background on competitive programming is required. I think that the book is useful for future IOI participants, as the book covers most topics in the IOI syllabus.

The final version of the book will be ready later this year. The PDF version of the book will be available for free also in the future, and in addition, there will be a printed version that will cost something.

Before the final version, I will do small fixes, improve the language and add references. Of course, I appreciate all feedback on the book — you can send it to this blog or directly to me.

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

»
8 months ago, # |
  Vote: I like it +6 Vote: I do not like it

YOU HELPED IN A GREAT WAY ____///////////////\\\\\\\\\\\________ A BIG SALUTE

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +6 Vote: I do not like it

    iN last of every chapter makeexercise of some problems of various ojs

»
8 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Good job!

»
8 months ago, # |
Rev. 2   Vote: I like it +13 Vote: I do not like it

I love it :) But I think you can add more problems , and more advanced topics too

»
8 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Are certain sections highlighted at the start of the section that its exclusively for ICPC participants? So that those aiming for IOI may not go in much deep! Thank you Keep up the good work

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +14 Vote: I do not like it

    At the moment there is no such classification, but it might be a good idea. However, new topics are regularly added to the IOI syllabus, so it is difficult to say what is needed in future years. I also think that all topics in the book are worth learning, even if they are not in the IOI syllabus at the moment. :)

    • »
      »
      »
      7 months ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      You gave almost 1 paragraph about persistence segtree,sqrt decomposition.That's not fair

    • »
      »
      »
      7 months ago, # ^ |
      Rev. 3   Vote: I like it -16 Vote: I do not like it

      I COMPLETED STUDYING YOUR WHOLE BOOK.

      THIS WAS A NICE BOOK.

      I LEARNED A LOT.THANKS FROM MY HEART.

»
8 months ago, # |
  Vote: I like it +33 Vote: I do not like it

Logged in just to Upvote this blog and say thank you to pllk. Great job :)

»
8 months ago, # |
Rev. 2   Vote: I like it +17 Vote: I do not like it

Thank you! I think it is a really good book with very focused content. Just a suggestion, maybe you could include some competitive programming tricks into your book? For example, how to write a shortened version of a common algorithm (e.g. union-find can be written in 4 statements without using union-by-rank heuristic and is still good enough in competitions)?

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +9 Vote: I do not like it

    You are right, I should at least mention the other heuristic. I have used the union-by-size heuristic, because I think it is both easy to code and explain why it works in logarithmic time.

»
8 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Thank you for sharing. The book is well written. Definitely a plus!

»
8 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Very useful and well written :)

»
8 months ago, # |
  Vote: I like it +90 Vote: I do not like it

Wow, this looks like a tremendous amount of work. I'm really curious about a few things.

How long did it take you? How old are you and are you a teacher? Have you written it in your free time, without the money compensation from e.g. university?

  • »
    »
    8 months ago, # ^ |
    Rev. 2   Vote: I like it -6 Vote: I do not like it

    You can guess the answers of the some questions by his IOI profile.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +170 Vote: I do not like it

    Good questions. I'm 29 now and I teach (among other things) at university.

    It has been a long project, I started it in about 2013. First I wrote the book in Finnish (and rewrote it several times because I was not satisfied), and finally I decided to translate it into English (because most people can't read Finnish).

    It is my free time project without salary, this is also one reason why it took so long time. But I've learned a lot, both about competitive programming and writing.

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +18 Vote: I do not like it

      The amount of hard work truly shows up in the explanation of your book. Thank you for making it "priceless" :)

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +94 Vote: I do not like it

      You made great job, thank you. How we can donate you?

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Brother its fantastic. I salute you.

»
8 months ago, # |
  Vote: I like it +18 Vote: I do not like it

I think this may be the best competitive programming book for beginners, I've ever seen! I've read some of Competitive Programming by Steven Halim already, and I would say that it is indeed a good book. However, truth be told I don't think it is necessarily beginner friendly. The way the sample code is written makes it somewhat difficult to read at times. Personally, I didn't know much C++ when I started to read it so the constant one-liner "if" and "for" statements he often uses obscured the meaning behind a lot of algorithms, for a few weeks, at times. So the clean code in your book is a huge plus.

One reason I can see this book being the best beginner book is that you "spell out" everything for the reader. I read the chapter on bit manipulation and I certainly believe it is the most well-written piece of literature on it I've ever seen. I don't think I've ever seen a coherent article written on using bitmasks for DP problems written for beginners either, and I can't wait to sink my teeth into the remainder of the book.

»
8 months ago, # |
  Vote: I like it +8 Vote: I do not like it

Awesome Work !! You can add some related problems in each chapter.

»
8 months ago, # |
  Vote: I like it +67 Vote: I do not like it

If you share the book sources, the community can translate it to other languages.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +38 Vote: I do not like it

    The source code is available here: https://github.com/pllk/cphb

    It would be great if somebody would like to translate the book (after the final version is ready).

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Do you think it's a good idea to start translating it now or is it better to wait for the final version?

      • »
        »
        »
        »
        7 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        There are still some issues I have to fix, but they are small things and there will be no remarkable changes.

        So it's already possible to start translating, and I'm very happy if somebody would like to do it. But please contact me before starting so that I know who is doing what.

»
8 months ago, # |
Rev. 7   Vote: I like it +59 Vote: I do not like it

I read some prefix of the book

It's easy to read (but I didn't find anything new yet but that's pretty normal I suppose)

What I want you to consider is to promote a cleaner code. I think it's quite important especially when there are more than 1 coder in a team (but i find it useful even when I participate in personal contest)

What I mean, for example:

  • When discussing defines for cycles, you may discuss pros and cons (e.g typing speed vs readability and harder to spot errors) (how your FOR will work when iterating from 10^10 to 10^10+5 ?)
  • I find 1-indexed arrays very questionable
  • (that's more debatable) binary search in my opinion is more handsome when formulated in terms of invariant f(l) = true, f(r) = false:
while(r - l > 1) {
   int m = (l + r) / 2;
   if (f(m)) {
      l = m;
   }
   else {
      r = m;
   }
  • fixed size arrays (e.g in graph representation)
  • understandable names (e.g array of used vertices in dfs)

By the way, You explain how to sort vector before introducing what it is, so may be it's worth moving sorting chapter after the introduction of vector because or at least say something like if you don't know what it's don't worry, you'll know in the next section.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +38 Vote: I do not like it

    Good points, I'll try to improve code readibility and other things you mentioned.

    It is very difficult to decide when to use 0-indexing and 1-indexing. In algorithm theory 1-indexing is usually more convenient (or look at any Codeforces problem), but of course C++ uses 0-indexing.

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Usually in CF problems you decrease by 1 while reading everything 1-indexed and after that you don't fight with the language :)

      • »
        »
        »
        »
        8 months ago, # ^ |
        Rev. 2   Vote: I like it +53 Vote: I do not like it

        Usually one doesn't do it. I went through AC-ed submissions of red/nutella people for 768G - The Winds of Winter. 7 of 18 used 0-indexing. Though I believe that 0-indexing is more common in two groups of people: Russians and Java users.

        That being said, I don't know which indexing should be used in books. I prefer 1-indexing.

        EDIT: typo in quite important place

        • »
          »
          »
          »
          »
          8 months ago, # ^ |
          Rev. 2   Vote: I like it +9 Vote: I do not like it

          That's why russians are so cool in ICPC

          Maybe I live in skewed reality of Russian bastards, then :)

        • »
          »
          »
          »
          »
          8 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Also more than 99% of Iranian experienced coders use 0-indexing(i.e. Reyna, Haghani, LiTi, mruxim, Narenji58). Is there any relation between Iranian coding style and Russians one?

        • »
          »
          »
          »
          »
          8 months ago, # ^ |
            Vote: I like it +73 Vote: I do not like it

          I believe 0-indexing is the only indexing used outside of competitive programming.

          • »
            »
            »
            »
            »
            »
            8 months ago, # ^ |
              Vote: I like it +5 Vote: I do not like it

            But 1-indexing is more people-friendly because we use 1-indexing everyday ("You got the 0-th place? Congratulatons!").

            It's also convenient to say "the first element of the sequence" and "the k-th city", so maybe 1-indexing is better for talking about algorithms. And I agree that 0-indexing is more convenient to code.

            • »
              »
              »
              »
              »
              »
              »
              7 months ago, # ^ |
                Vote: I like it 0 Vote: I do not like it

              "You got the 0-th place" Thats hilarious !!!

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +18 Vote: I do not like it

      Stick to 1-indexing, it's more common IRL.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +15 Vote: I do not like it

    (that's more debatable) binary search in my opinion is more handsome when formulated in terms of invariant f(l) = true, f(r) = false

    TRIGGERED!

    Actually, for this comment to not be completely useless I tried searching for my explanation of why I definitely prefer version presented in book. It is here: http://codeforces.com/blog/entry/17881?locale=en What is funny is that also there you were my main opposer ;p.

»
8 months ago, # |
Rev. 2   Vote: I like it +6 Vote: I do not like it

I've noticed that you add pairs t vector using v.push_back({1, 2}) and v.push_back(make_tuple(1, 2, 3)). I believe, braces initialisation should work for tuple too (and also you may use emplace_back) in either case

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Do you mean that I could replace

    vector<tuple<int,int>> v;
    v.push_back(make_tuple(2,3));
    

    with

    vector<tuple<int,int>> v;
    v.push_back({2,3});
    

    like with pairs? At least I couldn't compile the second code.

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Yep, that's what I meant.

      It compiles fine on ideone

      • »
        »
        »
        »
        8 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I see. This has to be a new feature. In Codeforces, if you use the compiler called "GNU G++14", it works, but if you use "GNU G++11", it doesn't work.

        • »
          »
          »
          »
          »
          8 months ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Seems like a bug in older g++ or in c++11. Both g++-6 and clang on my machine compile this fine in -std=c++11 mode.

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +16 Vote: I do not like it

      you must do v.emplace_back(2, 3) instead of v.push_back({2, 3})

»
8 months ago, # |
  Vote: I like it +5 Vote: I do not like it

A very well resourceful book.

»
8 months ago, # |
Rev. 2   Vote: I like it +30 Vote: I do not like it

Thanks a lot for the effort :) I think it would be great if you can add interesting sample problems for each topic and also add some more advanced techniques and algorithms. By the way, I would love to donate and to translate it into Turkish.

»
8 months ago, # |
  Vote: I like it +10 Vote: I do not like it

Thank you very much for your efforts. I literally learned more today than I did for the last month.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Surely great amount of work. But it will great if you add problem to practice section after every chapter of your book.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you. It'll help me a lot.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Wonderful book, and I think I'll use it often. But I do feel some important topics are missing. Perhaps they could be added into later editions? This could be another of the aspects where the codeforces community could help.

Topics that come to my mind would be fast exponentiation and its applications to DP, along with other dp optimizations like Knuth or convex hull trick, etc.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +39 Vote: I do not like it

    In fact, Chapter 23 discusses DP optimization with fast matrix exponentiation.

    But you are right, there are many advanced topics that are missing. I have plans for about 15 new chapters for the second edition of the book.

»
8 months ago, # |
Rev. 2   Vote: I like it +8 Vote: I do not like it

Method 2 for binary search would be cleaner if you change b = n/2 to b = (n+1)/2 and b /= 2 to b = (b + 1) / 2. This way you don't need the while loop.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +44 Vote: I do not like it

    Also, the data structure for minimum range queries is usually called Sparse Table.

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Good comments. You can also change b=n/2 to b=n for a shorter code in this case. I will check how established the term 'sparse table' is. I have seen it but it sounds a bit strange.

      • »
        »
        »
        »
        8 months ago, # ^ |
          Vote: I like it +13 Vote: I do not like it

        I also heard a term "sparse table" many times.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    About the binary search implementation: it seems that more changes would be needed to remove the while loop, because if b = 1, then also (b + 1) / 2 = 1 and the loop would run forever.

    • »
      »
      »
      7 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Oh, right. I actually only use method 1. Maybe it would be best to modify it so that the loop iterates over all powers of two, like in the sparse table approach.

»
8 months ago, # |
  Vote: I like it +17 Vote: I do not like it

People like you , are a blessing for the entire coding community .. :) Thanks a lot :)

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

If you add some problem name from different oj in each section . It will be more helpful .

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +57 Vote: I do not like it

    Maybe a good solution would be to create an extra file (available on author's website) with links to problems for each chapter. This way it can keep being updated, and the book can just say "if you need problems about some topic, go to this website".

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Great solution

    • »
      »
      »
      8 months ago, # ^ |
        Vote: I like it +18 Vote: I do not like it

      This sounds good. Many people have asked for problems, so it is clear that something should be done. Personally I often don't like lists of problems in books.

      • »
        »
        »
        »
        7 months ago, # ^ |
          Vote: I like it -10 Vote: I do not like it

        Don't take it in wrong way. But you ruined some simple concepts by giving them in iterative form rathar than recursive one. examples:- segment trees,

      • »
        »
        »
        »
        7 months ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        Yes! I think they make books look ugly. Maybe we could make something like awesome-cpproblemslist then

»
8 months ago, # |
  Vote: I like it +10 Vote: I do not like it

хорошая книга

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks pllk, great work, and really amazing coverage of many topics, it would be really helpful to add some practice problems from OJs.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks!! Keep up the good work!!

»
8 months ago, # |
  Vote: I like it -6 Vote: I do not like it

Thanks alot ! it seems to be a really great effort !

HATS OFF :)

I had a quick dive through the book and I didn't find problems for practice , well I hope you add a lot of problems for practice after each chapter ( personally I like problems from OJs that have editorials like CF. ) ...

And I'm thinking of something like :

The problems you are going to add to the book may be structured like :

A- The problem link or name.

B- Hint for solving it.(In case of the reader couldn't solve.)

C- Author's code for solving it. (I think this would really help to fully understand your style and ideas mentioned in the book.)

The book need not to contain all A , B and C .... it can contain A only , and B&C can be on your website as Errichto already mentioned.

That's just an idea which I think would help.

And please keep the community posted when u commit updates to the book :). Thank you.

»
8 months ago, # |
  Vote: I like it +7 Vote: I do not like it

As it turns out, a lot of people are asking for practice problems. So I propose that you guys create a Wiki and make some top rated people willing to contribute an admin of the wiki. Anyone can add problems / editorials here and it will be approved if and only if the quality of the problem / editorial is high enough and actually helps someone to improve their skills.

  • »
    »
    8 months ago, # ^ |
    Rev. 2   Vote: I like it +58 Vote: I do not like it

    I don't see why pllk should be obliged to create this wiki. He has done more than enough already by just creating this book and I think the people asking for problems are, more or less, missing this purpose of this book. The book is entitled "Competitive Programmer's Handbook". In my opinion, it seems like a book for beginners to get their feet wet, and understand concepts and aspects of implementation in the process, and for intermediate people to use it as a reference manual when solving problems.

    The second reason why I'm against this idea of putting problems in the book is that there are more than enough posts on codeforces with titles such as "What are some good problems involving segment trees" or whatever, and I don't see how it is any at all difficult to simply search for them on the site. I mean just look here, here, and on the entire section of Hackerrank about data structures and algorithms, for instance. Since, this post came to my attention, it has become somewhat easier, or at least more straightforward to read the Competitive Programming book, since I can always use the handbook here as a reference for more "difficult" concepts.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thanks a lot brother.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The book is great. It would be awesome if you could add some practice problem after each topic from various online judge.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I haven't understood this line. Please someone explain me this line. In 2.2 Compexity Classes

A special property of square roots is that sqrt(n) = n/sqrt(n), so the square root sqrt(n) lies, in some sense, in the middle of the input.

  • »
    »
    8 months ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    It's in the middle in the sense that if you want to divide an input of size N into X parts each of size X, you choose the square root of N. A common case when you want to precompute some number of partial results. 'Middle' might not be the best word for this.

  • »
    »
    7 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Logarithmic sense: .

»
8 months ago, # |
  Vote: I like it +1 Vote: I do not like it

I've gone through the "Advanced Topics" part and my reaction while reading this book can be described as: wow wow wow wow wow wow.....

Thank you for sharing it.

»
8 months ago, # |
  Vote: I like it +6 Vote: I do not like it

Thanks loads n loads.

Here is a book I wish I would have got earlier. Went through graph portion. For the first time, I felt dfs, bfs, bellman, Dijkstra are reachable and can be coded.

So kind of you that you have kept it free for all. I will advice this if someone wants to enter competitve programming.

Thanks again. A big hug.

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Great Job :] Thanks you

»
8 months ago, # |
  Vote: I like it 0 Vote: I do not like it

It's nice of you to make it free. Thanks a lot :D

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Just picked this up recently, it was great. Especially for a beginner like me. I'm using it along with CP3 for practice.

Will look forward to the published edition !

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Love the book, especially the advanced topics section, which includes most of the material needed to become a mid-purple.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

thanks

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

THANKS SIRRR !!!!!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Great Help..

»
7 months ago, # |
Rev. 19   Vote: I like it 0 Vote: I do not like it

Your book is awesome. Thanks.

»
7 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

thanks and gratitude

»
7 months ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

very helpful book i think...thanks for this initiative jobs and salute to u

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

No doubt that this book is great. But without practice problem every book is incomplete.

I request to add some good practice problems for each topic.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you very very very much!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank you for such an amazing book! Im wondering if theres an available epub version of this book?

»
7 months ago, # |
Rev. 5   Vote: I like it +18 Vote: I do not like it

In page 259, chapter 29: Geometry, I think it should be:

P a = {4,2};
P b = {3,-1};
cout << abs(b-a) << "\n"; // 3.16228

Instead:

P a = {4,2};
P b = {3,-1};
cout << abs(b-a) << "\n"; // 3.60555

Using the formular, we got:

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You can add Bertrand's postulate to number theory chapter:

There are at least one prime p such that n < p < 2n where n > 1.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

The book is amazing, really helpful and streight forward, gives you whatever you need with accurate examples and short explainations just like how you want it, so youll never get bored of a topic! Will be such a masterpiece if u include some suggessions for problems to initiate with for every topic, am sure codeforces has alot and members are ready to help for that. Salute, keep up the good work!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

It's so amazing!

Could you add build() for RMQ, ST and FW? I picked up the ideas about how to run update() and query() but wasn't good enough to understand how I can get these 'builded' arrays.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Thank You

»
7 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Can someone please send me the code for K-th ancestor in a successor graph. I have understood the algorithm but still not clear about writing the code. Thanks in advance.

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

THANK YOU!

»
7 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Really its very very helping for newbie coders like me.I am consistently reading this book and in fact it gives me a direction how to pracise. Many concepts of the book are standard concepts and used as it is while solving problems of codeforces. It improves my speed ,knowledge and accuracy rating also . Thank you very very much for publishing it. If possible please update this and add new topics. Thankyou very much pllk

»
7 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

OH my go-----------d!!! This is really an excellent book for a beginner like me. People learn from each other, share with each other and inspire each other. This is how the world develops generation by generation. I think this world needs people like you. With great power comes great responsibility!! Thank you so much for your invaluable contribution!!

»
6 months ago, # |
  Vote: I like it +1 Vote: I do not like it

This is #1 on HN right now: Thread. There's a bunch of feedback so I thought you should know. :)

  • »
    »
    6 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Lots of people there really don't like competitive programming, sad!

    • »
      »
      »
      6 months ago, # ^ |
      Rev. 2   Vote: I like it +11 Vote: I do not like it

      Competitive programming threads on most sites seem to degenerate into technical interview bashing.

      • »
        »
        »
        »
        6 months ago, # ^ |
        Rev. 2   Vote: I like it +5 Vote: I do not like it

        Yeah, I was disappointed that some people digressed to interview bashing on that thread, but others liked the book. Also, my thanks to the author of the book.

    • »
      »
      »
      8 days ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      You can understand them :)

      cp code:

      in m;
      cin>>m;
      VI a(m);
      forn(i,m)
        cin>>a[i];
      sort(all(a));
      prv.resize(m);
      VVI isp(mxpp,VI(mxpp*mxsc));
      

      Real life code:

      var maybeVCenterConnectionSettings = connectionSettingsDialog.ShowDialogEx();
      
      await maybeVCenterConnectionSettings.ApplyAsync(async connectionSettings =>
      {
          var gridEntryInConnectingState = VCenterConnectionDescriptor.CreateInConnectingState(
              infrastructureAddress: connectionSettings.Address);
      
          AddGridEntry(gridEntryInConnectingState);
      
          (await _serviceProvider.ConnectionsManager.AddConnectionAsync(connectionSettings))
              .OnSuccess(endpointDescriptor => AddGridEntry(endpointDescriptor))
              .OnFailure(processServiceError: ShowServiceRequestFailure);
      });
      
»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Hey @pllk, thank you very much! By the way, do you have the printed version available for purchase? I would love to buy this book.

  • »
    »
    6 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Not yet but it will be released later. I will announce here when it is ready. :)

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Latest draft dated 3 April, 2017

»
5 months ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

hey pllk

thank you very much for your awesome work

your book was very helpful to me

i'm using it to train for the IEEEXtreme programming competition

which — by the way — will be on October the 14th .

so if i may ask you ... will your book be ready before the competition or not ?

  • »
    »
    5 months ago, # ^ |
      Vote: I like it +18 Vote: I do not like it

    Thank you! You can consider the current version as ready, no new contents will be added.

»
5 months ago, # |
Rev. 7   Vote: I like it +8 Vote: I do not like it

How can the complexity of Bellman-Ford algorithm implementation in the book be O(N.M) ? shouldn't this code be O(N^2.M) UPDATE: O(N^2.NM) ? (Although the real algorithm complexity is O(N.M) !)

Book page : 123

  • »
    »
    5 months ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    Good point! Actually the complexity of the above implementation is O(n(n + m)), because the innermost loop will be iterated a total of m times during a round. However, the current revision of the book (page 125) already contains a better implementation whose time complexity is truly O(nm).

    • »
      »
      »
      5 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      Current revision ?

      Could you please create something like e-mail subscription! This would be very helpful to notify the community about updates and changes made to the book. Thanks :)

  • »
    »
    3 months ago, # ^ |
    Rev. 2   Vote: I like it +15 Vote: I do not like it

    You're saying that, for example, a dfs will take O(NM) or so. Be careful, learn how to get the complexity of a dfs or equivalently, of this code

    for(int a=1; a<=n; a++){
       for(auto b : v[a]){
           //O(1) operations
       }
    }
    

    Both dfs or this will take O(N + M), why? try to think about it.

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

I have huge respect for you _/_ thanks for all those effort in creating this excellent book and i will say to all top rated programmers to please contribute in this project.

»
4 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Does the book talk about how to problem solve?

  • »
    »
    3 months ago, # ^ |
      Vote: I like it +5 Vote: I do not like it

    What does that even mean?

    • »
      »
      »
      3 months ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      I mean breaking down a problem into small pieces so the overall problem becomes easier to solve. Basically showing the steps of how to solve a difficult competitive programming problem.

»
3 months ago, # |
  Vote: I like it +3 Vote: I do not like it

In the greedy Section Minimizing sums
there are a solution for this:
Minimize (a1-x)^2 + (a2-x)^2 + (a3-x)^2 .... (an-x)^2
And the solution is x = (average (Ai) )
That is because the average is the avarage of the
polynomial roots from nx^2 -2x(a1+a2+...+an)

Someone could explain me why works please??
How prove this??
And it works for every power different to 2?

  • »
    »
    3 months ago, # ^ |
      Vote: I like it -8 Vote: I do not like it

    It is the point where parabola has its minimal value. Google 'derivatives' and learn more

»
3 months ago, # |
  Vote: I like it 0 Vote: I do not like it

You can update file because it died

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

It's such a captivating textbook on competitive programming. Since I'm novice to competitive programming,I had a lot of issue like what's the most effective way to study,what algorithms and ds I should and the list goes on !! I had a lot of confusion and vague thinking. I'm currently reading your book and sometimes it seems hard to comprehend certain concepts. Where I should discuss it??

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

Can we discuss our doubts which we encounter while reading the book???

»
9 days ago, # |
  Vote: I like it 0 Vote: I do not like it

Very useful book, thanks!