Quake's blog

By Quake, 9 years ago, In English

What are some of the useful c++ commands or hacks helpful in competitive programming?

  • Vote: I like it
  • 0
  • Vote: I do not like it

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

#include <bits/stdc++.h> is a beauty(basically, it includes everything you will ever need in a contest). Another "hack" that I like a lot is casting an integer to a bitset and then couting that bitset, it helps a lot in debugging bitmaasks ant the like. Other than that, practice, practice and more practice!

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Can u provide an example to illustrate the second part of your answer(casting an integer,debugging bitmasks)?Since i'm a beginner,i'm not able to understand that.

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

      Like this. Debugging is just a use of it, sometimes you do a lot of bit-fiddling in an algo and you want to track down an error, but it may also help to cout the binary representation of a number if a problem asks for it, etc...

  • »
    »
    9 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Include it, and add at least 1 second to your compiler time :(