Posts

Showing posts from September, 2021

hashing Competitive programming

  #include <bits/stdc++.h> using   namespace   std ; #define   vi   vector < int > #define   pii   pair < int ,  int > #define   vii   vector < pii > #define   rep ( i ,  a ,  b )  for ( int  i = a; i < b; i ++ ) #define   ff  first #define   ss  second #define   setBits ( x )  builtin_popcount (x) struct   Node {      int  key;      Node   * left,  * right; }; Node *   newNode ( int   key ) {      Node *  node = new   Node ;     node->key = key ;     node->left = node->right = NULL ;      return  node; } void   getVerticalOrder ( Node *   root ,  int   hdis ,  map < int ,  vi >  & m ) {      if ( root == NULL )       return ;             m [ hdis ] . push_back ( root ->key);       getVerticalOrder ( root ->left,  hdis - 1 ,  m );       getVerticalOrder ( root ->right,  hdis + 1 ,  m );       } signed   main (){      Node   * root = newNode ( 10 );     root->left = newNode ( 7 );     root->right = newNode ( 4 );     root->