-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBlogs.txt
134 lines (110 loc) · 4.7 KB
/
Blogs.txt
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
Tricks-
http://codeforces.com/blog/entry/15643
https://codeforces.com/blog/entry/75456
In questions related to strings when n can 10^5 one possible way to approach could be character wise i.e. rep(i,0,26){rep(j,0,n){}}
eg- https://codeforces.com/contest/519/problem/D
suppose a 2-D matix is given as 1-D form as ROW MAJOR. if an elements index is i in 1-D then in 2-D
col number=i%col
row number=i/col
DP
https://apps.topcoder.com/forums/?module=Thread&start=0&threadID=697369
https://codeforces.com/blog/entry/43256
https://codeforces.com/blog/entry/45068
https://codeforces.com/blog/entry/53925 ==>Nisiyama_Suzune's blog
he/she covers advanced maths topics
https://codeforces.com/blog/entry/77298=> slope trick
https://codeforces.com/blog/entry/15296 ==>Adamant's dynamic connectivity
https://codeforces.com/blog/entry/45223 ==>SOS Dynamic Programming
https://www.quora.com/q/threadsiiithyderabad?sort=top => Lalit Kundu's Blog
http://codeforces.com/blog/entry/70467 => ouuan segment tree template
//struct with initialisation...
struct node{
ll p0,p1,p2,p3;
node(ll one,ll two,ll three,ll four):
p0{one},p1{two},p2{three},p3{four} {}
ll v[4]={p0,p1,p2,p3};
};
comparator => bool func(a,b);
if you want to sort ascending => return b<a;
if you want to sort descending => return a<b;
in general i feel like the order is in which the arguments appear is assumed to be the correct order, then you should return true if that ordering is correct and false if thats not the case.
writing comparators for set in cpp
struct cmp{
bool operator()(int a,int b){
return a>b;
}
};
------------------------------------------------------------------------
order statistics tree
https://codeforces.com/blog/entry/11080
policy based data structures
#include <ext/pb_ds/assoc_container.hpp>
#define ok(x) order_of_key(x)
#define fo(x) find_by_order(x)
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> os;
------------------------------------------------------------------------
Seg Tree-
https://codeforces.com/blog/entry/44478?#comment-290116
https://codeforces.com/blog/entry/44478?#comment-290057
https://codeforces.com/blog/entry/15890
interesting problems that i've solved with seg trees...
number of smaller elements in left side.
kth smaller number.
deleting elements from array cses-1749
------------------------------------------------------------------------
Perseg Tree-
https://discuss.codechef.com/t/distnum2-editorial/12566
------------------------------------------------------------------------
Rectangular Grid Walking
https://brilliant.org/wiki/rectangular-grid-walk-no-restriction/
------------------------------------------------------------------------
KMP-booth's algorithm
The Booth's algorithm uses a modified version of the KMP preprocessing function to find the lexicographically minimal string rotation. The failure function is progressively calculated as the string is rotated.
https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm#Variants
int rot(string s){
s+=s;
int n=s.length();
int f[n];
rep(i,0,n)f[i]=-1;
int k=0;
rep(j,1,n){
int sj=s[j];
int i=f[j-k-1];
while(i!=-1 && sj!=s[k+i+1]){
if(sj<s[k+i+1])k=j-i-1;
i=f[i];
}
if(sj!=s[k+i+1]){
if(sj<s[k])k=j;
f[j-k]=-1;
}
else{
f[j-k]=i+1;
}
}
return k;
}
--------------------------------------------------------------------------
Implementation of LONGEST PALINDROMIC SUBSTRING(MANACHER'S)
https://www.geeksforgeeks.org/manachers-algorithm-linear-time-longest-palindromic-substring-part-4/
--------------------------------------------------------------------------
PLAYLISTS
https://www.youtube.com/playlist?list=PLi0ZM-RCX5nvImim3_ilsdLOtDDkOWt-X
https://www.youtube.com/playlist?list=PLixpXjrHOw3YDrcGY1Y6yCAAyuFsmKNZK
https://www.youtube.com/playlist?list=PLi0ZM-RCX5nsTc2Z6woHr5qoF6n3b-thO
--------------------------------------------------------------------------
representation of a number as diff of squares :-https://qr.ae/pNvqR2
IMPORTANT FACT
upper bound for number of divisors for n => n^(1/3)
upper bound for number of primes less than n => n/(ln(n)-1.0836)
lower bound for number of primes less than n => n/ln(n)
--------------------------------------------------------------------------
MO's algorithm on Trees
https://codeforces.com/blog/entry/68271
https://codeforces.com/blog/entry/43230
---------------------------------------------------------------------------
Rerooting Technique
https://codeforces.com/blog/entry/76150
https://codeforces.com/blog/entry/68142
https://codeforces.com/blog/entry/53265