Code & Algorithm Jottings

Memset

  • memset ( a , 0 , sizeof (a) ): Set array a to 00

  • memset ( a , -1 , sizeof (a) ): Set array a to 1-1

  • memset ( a , 0x3f , sizeof (a) ): Set array a to

Define & Typedef

  • If it's not nessecery, DO NOT USE DEFINE, because it will make some problem that you can't think for.

  • MUST NOT use define to write the function like min ( a , b ), because if you use it like min ( a (x) , b (x) ), if a (x) is smaller than b (x), a (x) will be calculate for two times, it's much slow than the STL.

  • If you want to write the type long long in another way, don't use #define int long long, use this:

typedef long long ll

Online / Unline Algorithm

  • Online algorithm: Give the answer after every query.

  • Unline algorithm: Give the answer while all query is asked.

Orders

  • DFS Order
DFS Order.png
  • In-Stack Order: The order that recursion a tree.

  • Out-Stack Order: As same as in-stack-order.

Explanations

  • DP: Dynamic Programming

  • LCA: Least Common Ancestors

  • RMQ: Range Minimum / Maximum Query