-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patheldiegorecortado.tex
296 lines (261 loc) · 9.54 KB
/
eldiegorecortado.tex
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
% LaTeXar con :
% pdflatex eldiego.tex
%"The PDF file may contain up to 25 pages of reference material, single-sided, letter or A4 size, with text and illustrations readable by a person with correctable eyesight without magnification from a distance of 1/2 meter."
\input{preamble.margenes.chicos.tex}
\begin{document}
\def\title{Caloventor en Dos - Universidad Nacional de Rosario}
\section{algorithm}%%%%%%%%%%%%%%%%%%ALGORITHM%%%%%%%%%%%%%%%%%%
\input{algorithm.tex}
\section{Estructuras}%%%%%%%%%%%%%%%%%%ESTRUCTURAS%%%%%%%%%%%%%%%%%%
\subsection{RMQ (static)}
Dado un arreglo y una operacion asociativa \emph{idempotente}, get(i, j) opera sobre el rango [i, j). Restriccion: LVL $\ge$ ceil(logn); Usar [ ] para llenar arreglo y luego build().
\cppfile{estructuras/rmq.static.cpp}
\subsection{RMQ (dynamic)}
\cppfile{estructuras/rmq.dynamic.cpp}
\subsection{RMQ (lazy)}
\cppfile{estructuras/rmq.lazy.cpp}
\subsection{RMQ (persistente)}
\cppfile[23-53]{estructuras/rmq.persistent.cpp}
\subsection{Fenwick Tree}
\cppfile{estructuras/fenwick.cpp}
\subsection{Union Find}
\cppfile{grafos/union.find.cpp}
\subsection{Disjoint Intervals}
\cppfile{estructuras/disjoint.intervals.cpp}
\subsection{RMQ (2D)}
\cppfile{estructuras/rmq.2d.cpp}
\subsection{Big Int}
\cppfile{estructuras/bigint.villa.cpp}
\subsection{HashTables}
\cppfile[16-30]{hash.cpp}
\subsection{Modnum}
\cppfile{estructuras/mnum.cpp}
\subsection{Treap para set}
\cppfile[16-89]{estructuras/treap.cpp}
\subsection{Treap para arreglo}
\cppfile[17-87]{estructuras/treaparr.cpp}
\subsection{Convex Hull Trick}
\cppfile[18-55]{estructuras/convexhull.trick.cpp}
\subsection{Convex Hull Trick (Dynamic)}
\cppfile[17-56]{estructuras/convexhull.trick.dyn.cpp}
%\subsection{Gain-Cost Set}
%\cppfile[20-43]{estructuras/gain-cost.set.cpp}
\subsection{Set con busq binaria}
\cppfile[17-26]{estructuras/order.tree.cpp}
\section{Algos}%%%%%%%%%%%%%%%%%%ALGORITMOS%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Longest Increasing Subsecuence}
\cppfile[14-42]{algos/lis.cpp}
\subsection{Alpha-Beta prunning}
\cppfile{algos/alphabeta.cpp}
\subsection{Mo's algorithm}
\cppfile{algos/mosalgorithm.cpp}
\section{Strings}%%%%%%%%%%%%%%%%%%STRINGS%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Manacher}
\cppfile[18-37]{string/manacher.cpp}
\subsection{KMP}
\cppfile[21-38]{string/kmp.cpp}
\subsection{Trie}
\cppfile{string/trie.cpp}
%\subsection{Suffix Array (corto, nlog2n)}
%\cppfile[12-26]{string/suffix.array.short.cpp}
\subsection{Suffix Array (largo, nlogn)}
\cppfile[-34]{string/suffix.array.cpp}
\subsection{String Matching With Suffix Array}
\cppfile[37-58]{string/suffix.array.cpp}
\subsection{LCP (Longest Common Prefix)}
\cppfile[60-75]{string/suffix.array.cpp}
\subsection{Corasick}
\cppfile[16-55]{string/corasick.cpp}
\subsection{Suffix Automaton}
\cppfile[16-61]{string/suffix.automaton.cpp}
\subsection{Z Function}
\cppfile[17-27]{string/zfunction.cpp}
\section{Geometria}%%%%%%%%%%%%%%%%%%GEOMETRIA%%%%%%%%%%%%%%%%%%%%%%
\subsection{Punto}
\cppfile[2-33]{geometria/pto.cpp}
\subsection{Orden radial de puntos}
\cppfile{geometria/orden.radial.cpp}
\subsection{Line}
\cppfile{geometria/line.cpp}
\subsection{Segment}
\cppfile{geometria/segm.cpp}
%\subsection{Rectangle}
%n\cppfile{geometria/rect.cpp}
\subsection{Polygon Area}
\cppfile{geometria/area.cpp}
\subsection{Circle}
\cppfile{geometria/circle.cpp}
\subsection{Point in Poly}
\cppfile{geometria/point.in.poly.cpp}
\subsection{Point in Convex Poly log(n)}
\cppfile{geometria/point.in.convex.poly.cpp}
%\subsection{Convex Check CHECK}
%\cppfile{geometria/convex.check.cpp}
\subsection{Convex Hull}
\cppfile{geometria/convex.hull.cpp}
\subsection{Cut Polygon}
\cppfile{geometria/cut.polygon.cpp}
\subsection{Bresenham}
\cppfile{geometria/bresenham.cpp}
%\subsection{Rotate Matrix}
%\cppfile{geometria/rotate.cpp}
\subsection{Interseccion de Circulos en n3log(n)}
\cppfile{geometria/int.circs.cpp}
\section{Math}%%%%%%%%%%%%%%%%%%MATH%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Identidades}
{
$\sum_{i=0}^n\binom{n}{i}=2^n$
$\sum_{i=0}^n i\binom{n}{i}=n*2^{n-1}$
$\sum_{i=m}^n i = \frac{n(n+1)}{2} - \frac{m(m-1)}{2} = \frac{(n+1-m)(n+m)}{2}$
$\sum_{i=0}^n i = \sum_{i=1}^n i = \frac{n(n+1)}{2}$
$\sum_{i=0}^n i^2 = \frac{n(n+1)(2n+1)}{6} = \frac{n^3}{3} + \frac{n^2}{2} + \frac{n}{6}$
$\sum_{i=0}^n i(i-1) = \frac{8}{6}(\frac{n}{2})(\frac{n}{2}+1)(n+1)$ (doubles) $\rightarrow$ Sino ver caso impar y par
$\sum_{i=0}^n i^3 = \left(\frac{n(n+1)}{2}\right)^2 = \frac{n^4}{4} + \frac{n^3}{2} + \frac{n^2}{4} = \left[\sum_{i=1}^n i\right]^2$
$\sum_{i=0}^n i^4 = \frac{n(n+1)(2n+1)(3n^2+3n-1)}{30} = \frac{n^5}{5} + \frac{n^4}{2} + \frac{n^3}{3} - \frac{n}{30}$
$\sum_{i=0}^n i^p = \frac{(n+1)^{p+1}}{p+1} + \sum_{k=1}^p\frac{B_k}{p-k+1}{p\choose k}(n+1)^{p-k+1}$
$r=e-v+k+1$
Teorema de Pick: (Area, puntos interiores y puntos en el borde)
$A=I+\frac{B}{2}-1$
}%
\subsection{Ec. Caracteristica}
$a_0T(n)+a_1T(n-1)+...+a_kT(n-k)=0$
$p(x)=a_0 x^k + a_1 x^{k-1} + ... + a_k$
Sean $r_1,r_2,...,r_q$ las raíces distintas, de mult. $m_1, m_2, ..., m_q$
$T(n)=\sum_{i=1}^q{\sum_{j=0}^{m_i - 1}c_{ij} n^j r_i^n}$
Las constantes $c_{ij}$ se determinan por los casos base.
\subsection{Combinatorio}
\cppfile{math/combinatorio.cpp}
\subsection{Exp. de Numeros Mod.}
\cppfile[2]{math/exp.mod.cpp}
\subsection{Exp. de Matrices}
\cppfile{math/exp.mat.cpp}
\subsection{Matrices y determinante $O(n^3)$}
\cppfile[17-52]{math/determinante.cpp}
\subsection{Teorema Chino del Resto}
$$y=\sum_{j=1}^n (x_j*(\prod_{i=1, i\neq j}^n m_i)_{m_j}^{-1}*\prod_{i=1, i\neq j}^n m_i)$$
\subsection{Criba}
\cppfile[19-34
]{math/criba.cpp}
\subsection{Funciones de primos}
Sea $n=\prod{p_i^{k_i}}$, fact(n) genera un map donde a cada $p_i$ le asocia su $k_i$
\cppfile[33-88]{math/func.primos.cpp}
\subsection{Phollard's Rho (rolando)}
\cppfile{math/phollards.rho.villa.cpp}
\subsection{GCD}
\begin{code}
tipo gcd(tipo a, tipo b){return a?gcd(b %a, a):b;}
\end{code}
\subsection{Extended Euclid}
\cppfile{math/extended.euclid.cpp}
\subsection{LCM}
\begin{code}
tipo lcm(tipo a, tipo b){return a / gcd(a,b) * b;}
\end{code}
\subsection{Inversos}
\cppfile[7-16]{math/inversos.cpp}
\subsection{Simpson}
\cppfile{math/simpson.cpp}
\subsection{Fraction}
\cppfile{math/frac.cpp}
\subsection{Polinomio}
\cppfile[16-74]{math/polinomio.cpp}
\subsection{Ec. Lineales}
\cppfile[29-62]{math/eclineales.cpp}
\subsection{FFT}
\cppfile[16-65]{math/fft.cpp}
\subsection{Tablas y cotas (Primos, Divisores, Factoriales, etc)}
%\subsubsection{
\paragraph{Cantidad de primos menores que $10^n$}\ \\
$\pi(10^1)$ = 4 ;
$\pi(10^2)$ = 25 ;
$\pi(10^3)$ = 168 ;
$\pi(10^4)$ = 1229 ;
$\pi(10^5)$ = 9592 \\
$\pi(10^6)$ = 78.498 ;
$\pi(10^7)$ = 664.579 ;
$\pi(10^8)$ = 5.761.455 ;
$\pi(10^9)$ = 50.847.534 \\
$\pi(10^{10})$ = 455.052,511 ;
$\pi(10^{11})$ = 4.118.054.813 ;
$\pi(10^{12})$ = 37.607.912.018% ;
%
% Fuente: http://primes.utm.edu/howmany.shtml#table
%
%
%\subsubsection{Divisores}
\paragraph{Divisores} \ \\
Cantidad de divisores ($\sigma_0$) para \emph{algunos} $n / \neg\exists n'<n, \sigma_0(n') \geqslant \sigma_0(n)$ \\
$\sigma_0(60)$ = 12 ; $\sigma_0(120)$ = 16 ; $\sigma_0(180)$ = 18 ; $\sigma_0(240)$ = 20 ; $\sigma_0(360)$ = 24 \\
$\sigma_0(720)$ = 30 ; $\sigma_0(840)$ = 32 ; $\sigma_0(1260)$ = 36 ; $\sigma_0(1680)$ = 40 ; $\sigma_0(10080)$ = 72 \\ $\sigma_0(15120)$ = 80 ; $\sigma_0(50400)$ = 108 ; $\sigma_0(83160)$ = 128 ; $\sigma_0(110880)$ = 144 \\
$\sigma_0(498960)$ = 200 ; $\sigma_0(554400)$ = 216 ; $\sigma_0(1081080)$ = 256 ; $\sigma_0(1441440)$ = 288 $\sigma_0(4324320)$ = 384 ; $\sigma_0(8648640)$ = 448
\section{Grafos}%%%%%%%%%%%%%%%%%%GRAFOS%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Dijkstra}
\cppfile[6-23]{grafos/dijkstra.cpp}
\subsection{Bellman-Ford}
\cppfile{grafos/bellman.ford.cpp}
\subsection{Floyd-Warshall}
\cppfile{grafos/floyd.warshall.cpp}
\subsection{Kruskal}
\cppfile[27-41]{grafos/kruskal.cpp}
\subsection{Prim}
\cppfile[23-40]{grafos/prim.cpp}
\subsection{2-SAT + Tarjan SCC}
\cppfile{grafos/2sat.cpp}
\subsection{Articulation Points}
\cppfile{grafos/articulaciones.cpp}
\subsection{Comp. Biconexas y Puentes}
\cppfile[28-76]{grafos/biconexas.bridge.cpp}
\subsection{LCA + Climb}
\cppfile{grafos/lca.climb.cpp}
\subsection{Heavy Light Decomposition}
\cppfile[21-56]{grafos/heavylight.cpp}
\subsection{Centroid Decomposition}
\cppfile[17-36]{grafos/centroid.cpp}
\subsection{Euler Cycle}
\cppfile{grafos/euler.cpp}
\subsection{Diametro árbol}
\cppfile[17-41]{grafos/diametro.cpp}
\subsection{Chu-liu}
\cppfile{grafos/chuliu.villa.cpp}
\subsection{Hungarian}
\cppfile{grafos/hungarian.villa.cpp}
\subsection{Dynamic Conectivity}
\cppfile[17-78]{grafos/dynamic.conectivity.cpp}
\section{Network Flow}%%%%%%%%%%%%%%%%%%FLOW%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\subsection{Dinic}
\cppfile[12-66]{flow/dinic.cpp}
%\subsection{Konig}
%\cppfile[98-122]{flow/konig.cpp}
%\subsection{Edmonds Karp's}
%\cppfile{flow/edmonds.karps.cpp}
%\subsection{Push-Relabel O(N3)}
%\cppfile{flow/push.relabel.cpp}
\subsection{Min-cost Max-flow}
\cppfile[16-66]{flow/min.cost.max.flow.cpp}
\section{Template}%%%%%%%%%%%%%%%%%%TEMPLATE%%%%%%%%%%%%%%%%
\cppfile{template.cpp}
\section{Ayudamemoria}%%%%%%%%%%%%%%%%%%AYUDAMEMORIA%%%%%%%%%%%%%%%%
\subsection*{Leer hasta fin de linea}
\begin{code}
#include <sstream>
//hacer cin.ignore() antes de getline()
while(getline(cin, line)){
istringstream is(line);
while(is >> X)
cout << X << " ";
cout << endl;
}
\end{code}
\subsection*{Expandir pila}
\begin{code}
#include <sys/resource.h>
rlimit rl;
getrlimit(RLIMIT_STACK, &rl);
rl.rlim_cur=1024L*1024L*256L;//256mb
setrlimit(RLIMIT_STACK, &rl);
\end{code}
\subsection*{Iterar subconjunto}
\begin{code}
for(int sbm=bm; sbm; sbm=(sbm-1)&bm)
\end{code}
\end{document}