-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleetcode.cpp
More file actions
103 lines (83 loc) · 4.13 KB
/
Copy pathleetcode.cpp
File metadata and controls
103 lines (83 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fr(i,s,e) for(int i=s;i<e;++i)
#define fr1(i,s,e) for(int i=s;i>e;--i)
#define p0(a) cout << a <<" "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define INF (ll)1e18 + 100
#define v(d) vector<d>
#define all(x) (x).begin(), (x).end()
#define pr pair<int, int>
#define pr1(d1,d2) pair<d1,d2>
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define endl "\n"
#define sz(x) ((int)(x).size())
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*
find_by_order(k) -> returns pointer to k+1 th element in set
order_of_key(val) -> returns number of elements strictly less than val in the set
*/
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
const int mod = 1e9 +7;
const int mod1= 998244353;
#define debug(x) cout << #x <<" "; _print(x); cout << endl;
// #define debug(x)
void _print(ll t) {cout << t;}
void _print(int t) {cout << t;}
void _print(string t) {cout << t;}
void _print(char t) {cout << t;}
void _print(lld t) {cout << t;}
void _print(double t) {cout << t;}
void _print(ull t) {cout << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cout << "{"; _print(p.ff); cout << ","; _print(p.ss); cout << "}";}
template <class T> void _print(vector <T> v) {cout << "[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(set <T> v) {cout << "[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T> void _print(multiset <T> v) {cout << "[ "; for (T i : v) {_print(i); cout << " ";} cout << "]";}
template <class T, class V> void _print(map <T, V> v) {cout << "[ "; for (auto i : v) {_print(i); cout << " ";} cout << "]";}
int ad(int a, int b){
a = (a+mod)%mod;
b = (b+mod)%mod;
return (a+b)%mod;
}
int mul(int a, int b){
return (1ll*a*b)%mod;
}
/******************
Size Timelimit Sure Shot Try
1. n <= 200 1s n^3 n^4 (with pruning)
2. n <= 500 1s n^3(small prune) n^4 (with pruning)
3. n <= 5000 1s n^2
4. n <= 2*10^5 1s nLogn n(rootN) may work in some cases
5. n <= 10^6 1s nLogn
If Timelimit > 1s, Scale them accordingly.
Code belongs to:
▄████▄ ██░ ██ ▄▄▄ ███▄ █ ▄████ ▒█████ ██▓
▒██▀ ▀█ ▓██░ ██▒▒████▄ ██ ▀█ █ ██▒ ▀█▒▒██▒ ██▒▓██▒
▒▓█ ▄ ▒██▀▀██░▒██ ▀█▄ ▓██ ▀█ ██▒▒██░▄▄▄░▒██░ ██▒▒██▒
▒▓▓▄ ▄██▒░▓█ ░██ ░██▄▄▄▄██ ▓██▒ ▐▌██▒░▓█ ██▓▒██ ██░░██░
▒ ▓███▀ ░░▓█▒░██▓ ▓█ ▓██▒▒██░ ▓██░░▒▓███▀▒░ ████▓▒░░██░
░ ░▒ ▒ ░ ▒ ░░▒░▒ ▒▒ ▓▒█░░ ▒░ ▒ ▒ ░▒ ▒ ░ ▒░▒░▒░ ░▓
░ ▒ ▒ ░▒░ ░ ▒ ▒▒ ░░ ░░ ░ ▒░ ░ ░ ░ ▒ ▒░ ▒ ░
░ ░ ░░ ░ ░ ▒ ░ ░ ░ ░ ░ ░ ░ ░ ░ ▒ ▒ ░
░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░
░
**************/