Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge LaTeX fix #269

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
LATEXCMD = pdflatex -shell-escape -output-directory build/
FLAGFILE = build/.flag
export TEXINPUTS=.:content/tex/:
export max_print_line = 1048576

Expand All @@ -17,11 +18,11 @@ help:
@echo ""
@echo "For more information see the file 'doc/README'"

fast: | build
fast: | build $(FLAGFILE)
$(LATEXCMD) content/kactl.tex </dev/null
cp build/kactl.pdf kactl.pdf

kactl: test-session.pdf | build
kactl: test-session.pdf | build $(FLAGFILE)
$(LATEXCMD) content/kactl.tex && $(LATEXCMD) content/kactl.tex
cp build/kactl.pdf kactl.pdf

Expand All @@ -33,6 +34,9 @@ veryclean: clean

.PHONY: help fast kactl clean veryclean

$(FLAGFILE): build
rm -f build/kactl.* build/test-session.* && touch $(FLAGFILE)

build:
mkdir -p build/

Expand All @@ -42,7 +46,7 @@ test:
test-compiles:
./doc/scripts/compile-all.sh .

test-session.pdf: content/test-session/test-session.tex content/test-session/chapter.tex | build
test-session.pdf: content/test-session/test-session.tex content/test-session/chapter.tex | build $(FLAGFILE)
$(LATEXCMD) content/test-session/test-session.tex
cp build/test-session.pdf test-session.pdf

Expand Down
2 changes: 1 addition & 1 deletion content/appendix/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\appendix
\chapter{Techniques}
\section{Techniques}

\kactlimport[-l raw]{techniques.txt}
36 changes: 18 additions & 18 deletions content/combinatorial/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
\chapter{Combinatorial}
\section{Combinatorial}

\section{Permutations}
\subsection{Factorial}
\subsection{Permutations}
\subsubsection{Factorial}
\import{factorial.tex}
\kactlimport{IntPerm.h}

\subsection{Cycles}
\subsubsection{Cycles}
Let $g_S(n)$ be the number of $n$-permutations whose cycle lengths all belong to the set $S$. Then
$$\sum_{n=0} ^\infty g_S(n) \frac{x^n}{n!} = \exp\left(\sum_{n\in S} \frac{x^n} {n} \right)$$

\subsection{Derangements}
\subsubsection{Derangements}
Permutations of a set such that none of the elements appear in their original position.
\[ \mkern-2mu D(n) = (n-1)(D(n-1)+D(n-2)) = n D(n-1)+(-1)^n = \left\lfloor\frac{n!}{e}\right\rceil \]

\subsection{Burnside's lemma}
\subsubsection{Burnside's lemma}
Given a group $G$ of symmetries and a set $X$, the number of elements of $X$ \emph{up to symmetry} equals
\[ {\frac {1}{|G|}}\sum _{{g\in G}}|X^{g}|, \]
where $X^{g}$ are the elements fixed by $g$ ($g.x = x$).

If $f(n)$ counts ``configurations'' (of some sort) of length $n$, we can ignore rotational symmetry using $G = \mathbb Z_n$ to get
\[ g(n) = \frac 1 n \sum_{k=0}^{n-1}{f(\text{gcd}(n, k))} = \frac 1 n \sum_{k|n}{f(k)\phi(n/k)}. \]

\section{Partitions and subsets}
\subsection{Partition function}
\subsection{Partitions and subsets}
\subsubsection{Partition function}
Number of ways of writing $n$ as a sum of positive integers, disregarding the order of the summands.
\[ p(0) = 1,\ p(n) = \sum_{k \in \mathbb Z \setminus \{0\}}{(-1)^{k+1} p(n - k(3k-1) / 2)} \]
\[ p(n) \sim 0.145 / n \cdot \exp(2.56 \sqrt{n}) \]
Expand All @@ -34,14 +34,14 @@ \section{Partitions and subsets}
\end{tabular}
\end{center}

\subsection{Lucas' Theorem}
\subsubsection{Lucas' Theorem}
Let $n,m$ be non-negative integers and $p$ a prime. Write $n=n_kp^k+...+n_1p+n_0$ and $m=m_kp^k+...+m_1p+m_0$. Then $\binom{n}{m} \equiv \prod_{i=0}^k\binom{n_i}{m_i} \pmod{p}$.

\subsection{Binomials}
\subsubsection{Binomials}
\kactlimport{multinomial.h}

\section{General purpose numbers}
\subsection{Bernoulli numbers}
\subsection{General purpose numbers}
\subsubsection{Bernoulli numbers}
EGF of Bernoulli numbers is $B(t)=\frac{t}{e^t-1}$ (FFT-able).
$B[0,\ldots] = [1, -\frac{1}{2}, \frac{1}{6}, 0, -\frac{1}{30}, 0, \frac{1}{42}, \ldots]$

Expand All @@ -56,7 +56,7 @@ \section{General purpose numbers}
\[ \approx \int_{m}^\infty f(x)dx + \frac{f(m)}{2} - \frac{f'(m)}{12} + \frac{f'''(m)}{720} + O(f^{(5)}(m)) \]
\normalsize

\subsection{Stirling numbers of the first kind}
\subsubsection{Stirling numbers of the first kind}
Number of permutations on $n$ items with $k$ cycles.
\begin{align*}
&c(n,k) = c(n-1,k-1) + (n-1) c(n-1,k),\ c(0,0) = 1 \\
Expand All @@ -65,29 +65,29 @@ \section{General purpose numbers}
$c(8,k) = 8, 0, 5040, 13068, 13132, 6769, 1960, 322, 28, 1$ \\
$c(n,2) = 0, 0, 1, 3, 11, 50, 274, 1764, 13068, 109584, \dots$

\subsection{Eulerian numbers}
\subsubsection{Eulerian numbers}
Number of permutations $\pi \in S_n$ in which exactly $k$ elements are greater than the previous element. $k$ $j$:s s.t. $\pi(j)>\pi(j+1)$, $k+1$ $j$:s s.t. $\pi(j)\geq j$, $k$ $j$:s s.t. $\pi(j)>j$.
$$E(n,k) = (n-k)E(n-1,k-1) + (k+1)E(n-1,k)$$
$$E(n,0) = E(n,n-1) = 1$$
$$E(n,k) = \sum_{j=0}^k(-1)^j\binom{n+1}{j}(k+1-j)^n$$

\subsection{Stirling numbers of the second kind}
\subsubsection{Stirling numbers of the second kind}
Partitions of $n$ distinct elements into exactly $k$ groups.
$$S(n,k) = S(n-1,k-1) + k S(n-1,k)$$
$$S(n,1) = S(n,n) = 1$$
$$S(n,k) = \frac{1}{k!}\sum_{j=0}^k (-1)^{k-j}\binom{k}{j}j^n$$

\subsection{Bell numbers}
\subsubsection{Bell numbers}
Total number of partitions of $n$ distinct elements. $B(n) =$
$1, 1, 2, 5, 15, 52, 203, 877, 4140, 21147, \dots$. For $p$ prime,
\[ B(p^m+n)\equiv mB(n)+B(n+1) \pmod{p} \]

\subsection{Labeled unrooted trees}
\subsubsection{Labeled unrooted trees}
\# on $n$ vertices: $n^{n-2}$ \\
\# on $k$ existing trees of size $n_i$: $n_1n_2\cdots n_k n^{k-2}$ \\
\# with degrees $d_i$: $(n-2)! / ((d_1-1)! \cdots (d_n-1)!)$

\subsection{Catalan numbers}
\subsubsection{Catalan numbers}
\[ C_n=\frac{1}{n+1}\binom{2n}{n}= \binom{2n}{n}-\binom{2n}{n+1} = \frac{(2n)!}{(n+1)!n!} \]
\[ C_0=1,\ C_{n+1} = \frac{2(2n+1)}{n+2}C_n,\ C_{n+1}=\sum C_iC_{n-i} \]
${C_n = 1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862, 16796, 58786, \dots}$
Expand Down
2 changes: 1 addition & 1 deletion content/contest/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\chapter{Contest}
\section{Contest}

\kactlimport[-l rawcpp]{template.cpp}
\kactlimport[-l sh]{.bashrc}
Expand Down
2 changes: 1 addition & 1 deletion content/data-structures/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\chapter{Data structures}
\section{Data structures}

\kactlimport{OrderStatisticTree.h}
\kactlimport{HashMap.h}
Expand Down
12 changes: 6 additions & 6 deletions content/geometry/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
\chapter{Geometry}
\section{Geometry}

\section{Geometric primitives}
\subsection{Geometric primitives}
\kactlimport{Point.h}
\kactlimport{lineDistance.h}
\kactlimport{SegmentDistance.h}
Expand All @@ -12,15 +12,15 @@ \section{Geometric primitives}
% \kactlimport{LineProjectionReflection.h}
\kactlimport{Angle.h}

\section{Circles}
\subsection{Circles}
\kactlimport{CircleIntersection.h}
\kactlimport{CircleTangents.h}
% \kactlimport{CircleLine.h}
\kactlimport{CirclePolygonIntersection.h}
\kactlimport{circumcircle.h}
\kactlimport{MinimumEnclosingCircle.h}

\section{Polygons}
\subsection{Polygons}
\kactlimport{InsidePolygon.h}
\kactlimport{PolygonArea.h}
\kactlimport{PolygonCenter.h}
Expand All @@ -31,14 +31,14 @@ \section{Polygons}
\kactlimport{PointInsideHull.h}
\kactlimport{LineHullIntersection.h}

\section{Misc. Point Set Problems}
\subsection{Misc. Point Set Problems}
\kactlimport{ClosestPair.h}
% \kactlimport{ManhattanMST.h}
\kactlimport{kdTree.h}
% \kactlimport{DelaunayTriangulation.h}
\kactlimport{FastDelaunay.h}

\section{3D}
\subsection{3D}
\kactlimport{PolyhedronVolume.h}
\kactlimport{Point3D.h}
\kactlimport{3dHull.h}
Expand Down
22 changes: 11 additions & 11 deletions content/graph/chapter.tex
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
\chapter{Graph}
\section{Graph}

\section{Fundamentals}
\subsection{Fundamentals}
\kactlimport{BellmanFord.h}
\kactlimport{FloydWarshall.h}
\kactlimport{TopoSort.h}

\section{Network flow}
\subsection{Network flow}
\kactlimport{PushRelabel.h}
\kactlimport{MinCostMaxFlow.h}
\kactlimport{EdmondsKarp.h}
Expand All @@ -14,37 +14,37 @@ \section{Network flow}
\kactlimport{GlobalMinCut.h}
\kactlimport{GomoryHu.h}

\section{Matching}
\subsection{Matching}
\kactlimport{hopcroftKarp.h}
\kactlimport{DFSMatching.h}
\kactlimport{MinimumVertexCover.h}
\kactlimport{WeightedMatching.h}
\kactlimport{GeneralMatching.h}

\section{DFS algorithms}
\subsection{DFS algorithms}
\kactlimport{SCC.h}
\kactlimport{BiconnectedComponents.h}
\kactlimport{2sat.h}
\kactlimport{EulerWalk.h}

\section{Coloring}
\subsection{Coloring}
\kactlimport{EdgeColoring.h}

\section{Heuristics}
\subsection{Heuristics}
\kactlimport{MaximalCliques.h}
\kactlimport{MaximumClique.h}
\kactlimport{MaximumIndependentSet.h}

\section{Trees}
\subsection{Trees}
\kactlimport{BinaryLifting.h}
\kactlimport{LCA.h}
\kactlimport{CompressTree.h}
\kactlimport{HLD.h}
\kactlimport{LinkCutTree.h}
\kactlimport{DirectedMST.h}

\section{Math}
\subsection{Number of Spanning Trees}
\subsection{Math}
\subsubsection{Number of Spanning Trees}
% I.e. matrix-tree theorem.
% Source: https://en.wikipedia.org/wiki/Kirchhoff%27s_theorem
% Test: stress-tests/graph/matrix-tree.cpp
Expand All @@ -53,7 +53,7 @@ \section{Math}
Remove the $i$th row and column and take the determinant; this yields the number of directed spanning trees rooted at $i$
(if $G$ is undirected, remove any row/column).

\subsection{Erdős–Gallai theorem}
\subsubsection{Erdős–Gallai theorem}
% Source: https://en.wikipedia.org/wiki/Erd%C5%91s%E2%80%93Gallai_theorem
% Test: stress-tests/graph/erdos-gallai.cpp
A simple graph with node degrees $d_1 \ge \dots \ge d_n$ exists iff $d_1 + \dots + d_n$ is even and for every $k = 1\dots n$,
Expand Down
6 changes: 2 additions & 4 deletions content/kactl.tex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
\documentclass[9pt, a4paper, notitlepage]{extreport}
\documentclass[9pt,twoside]{extarticle}
\usepackage{kactlpkg}
\kactlcontentdir{content}

Expand All @@ -13,10 +13,8 @@
% Small KACTL header on the first page:
% \maketitle{``One Last Time'' Edition}{\today}
\begin{multicols*}{3}
\thispagestyle{fancy}
% Table of contents, without subsections:
\setcounter{tocdepth}{0}
\tableofcontents
\thispagestyle{fancy}

\kactlchapter{contest}
\kactlchapter{math}
Expand Down
Loading