Advertisement
Imran_Mohammed

Template

Jul 4th, 2022
1,284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.56 KB | None | 0 0
  1. //In the name of ALLAH
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5.  
  6. typedef long long ll;
  7. typedef vector<int> vi;
  8. typedef vector<ll> vl;
  9. typedef vector<vi> vvi;
  10. typedef vector<vl> vvl;
  11. typedef pair<int,int> pii;
  12. typedef pair<double, double> pdd;
  13. typedef pair<ll, ll> pll;
  14. typedef vector<pii> vii;
  15. typedef vector<pll> vll;
  16. typedef double dl;
  17.  
  18. #define PB push_back
  19. #define F first
  20. #define S second
  21. #define MP make_pair
  22. #define endl '\n'
  23. #define all(a) (a).begin(),(a).end()
  24. #define sz(x) (int)x.size()
  25. #define mid(l,r) ((r+l)/2)
  26. #define left(node) (node*2)
  27. #define right(node) (node*2+1)
  28. #define mx_int_prime 999999937
  29.  
  30. const double PI = acos(-1);
  31. const double eps = 1e-9;
  32. const int inf = 2000000000;
  33. const ll infLL = 9000000000000000000;
  34. #define MOD 1000000007
  35.  
  36. #define mem(a,b) memset(a, b, sizeof(a) )
  37. #define gcd(a,b) __gcd(a,b)
  38. #define sqr(a) ((a) * (a))
  39.  
  40. #define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  41. #define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
  42. #define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
  43.  
  44. typedef vector<int>::iterator vit;
  45. typedef set<int>::iterator sit;
  46.  
  47.  
  48. int dx[] = {0, 0, +1, -1};
  49. int dy[] = {+1, -1, 0, 0};
  50. //int dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
  51. //int dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
  52.  
  53.  
  54.  
  55. template < typename F, typename S >
  56. ostream& operator << ( ostream& os, const pair< F, S > & p ) {
  57.             return os << "(" << p.first << ", " << p.second << ")";
  58. }
  59.  
  60. template < typename T >
  61. ostream &operator << ( ostream & os, const vector< T > &v ) {
  62.             os << "{";
  63.                 for(auto it = v.begin(); it != v.end(); ++it) {
  64.                                 if( it != v.begin() ) os << ", ";
  65.                                         os << *it;
  66.                                             }
  67.                     return os << "}";
  68. }
  69.  
  70. template < typename T >
  71. ostream &operator << ( ostream & os, const set< T > &v ) {
  72.             os << "[";
  73.                 for(auto it = v.begin(); it != v.end(); ++it) {
  74.                                 if( it != v.begin() ) os << ", ";
  75.                                         os << *it;
  76.                                             }
  77.                     return os << "]";
  78. }
  79.  
  80. template < typename T >
  81. ostream &operator << ( ostream & os, const multiset< T > &v ) {
  82.             os << "[";
  83.                 for(auto it = v.begin(); it != v.end(); ++it) {
  84.                                 if( it != v.begin() ) os << ", ";
  85.                                         os << *it;
  86.                                             }
  87.                     return os << "]";
  88. }
  89.  
  90. template < typename F, typename S >
  91. ostream &operator << ( ostream & os, const map< F, S > &v ) {
  92.             os << "[";
  93.                 for(auto it = v.begin(); it != v.end(); ++it) {
  94.                                 if( it != v.begin() ) os << ", ";
  95.                                         os << it -> first << " = " << it -> second ;
  96.                                             }
  97.                     return os << "]";
  98. }
  99.  
  100. #define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
  101.  
  102. void faltu () {
  103.             cerr << endl;
  104. }
  105.  
  106. template <typename T>
  107. void faltu( T a[], int n ) {
  108.             for(int i = 0; i < n; ++i) cerr << a[i] << ' ';
  109.                 cerr << endl;
  110. }
  111.  
  112. template <typename T, typename ... hello>
  113. void faltu( T arg, const hello &... rest) {
  114.             cerr << arg << ' ';
  115.                 faltu(rest...);
  116. }
  117.  
  118.  
  119. int main()
  120. {
  121.     optimize();
  122.  
  123.     return 0;
  124. }
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement