Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
fshp971 committed May 16, 2022
0 parents commit 0fa6129
Show file tree
Hide file tree
Showing 69 changed files with 3,728 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.out
*.aux
*.log
*.~
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 fshp971

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ICPC-Template

本项目为个人整理/使用的算法竞赛模板TeX源码。

原版模板使用Pages编写,2018年底退役后再无更新,最近使用TeX复刻并开源。

由于本人能力有限,模板内容可能存在问题,欢迎提交issue。

## Requirements

- XeLaTeX (用于支持中文)[https://www.tug.org/texlive/](https://www.tug.org/texlive/)
- Pygments (用于支持minted语法高亮)[https://pygments.org/](https://pygments.org/)

## How to build

执行**两遍**如下命令:

```
xelatex -shell-escape icpc_template.tex
```

编译后生成的模板文件为`./icpc_template.pdf`

## License

本项目遵循[MIT](./LICENSE)开源协议。
39 changes: 39 additions & 0 deletions chapters/data_structure.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
\chapter{数据结构}

\def \codedir{./code/data_structure/}


\section{树状数组}
\inputcode{\codecpp}{\codedir/fenwick.cpp}


\section{RMQ}
\inputcode{\codecpp}{\codedir/rmq.cpp}


\section{可持久化可并堆}
\inputcode{\codecpp}{\codedir/heap.cpp}


\section{伸展树(Splay)}
\inputcode{\codecpp}{\codedir/splay.cpp}


\section{动态树(LCT)}
\inputcode{\codecpp}{\codedir/lct.cpp}


\section{KD-Tree}
\inputcode{\codecpp}{\codedir/kd_tree.cpp}


\section{虚树}
\inputcode{\codecpp}{\codedir/virtual_tree.cpp}


\section{笛卡尔树}
\inputcode{\codecpp}{\codedir/cartesian_tree.cpp}


\section{树分治找重心}
\inputcode{\codecpp}{\codedir/find_root.cpp}
67 changes: 67 additions & 0 deletions chapters/geometry.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
\chapter{计算几何}

\def \codedir{./code/geometry/}


\section{几何定理}

\subsection{正弦定理\&余弦定理}
设有三角形$ABC$, 其中$\angle A$, $\angle B$, $\angle C$的弧度分别为$\alpha$, $\beta$, $\gamma$, 对应的对边边⻓分别为 $|BC|=a$, $|AC|=b$, $|AB|=c$.
设该三角形的外接圆半径为$R$.
那么我们有如下定理:
\begin{itemize}
\item 正弦定理
\begin{gather*}
\frac{a}{\sin \alpha} = \frac{b}{\sin \beta} = \frac{c}{\sin \gamma} = 2R.
\end{gather*}

\item 余弦定理
\begin{gather*}
\left\{\begin{array}{l}
a^2 = b^2 + c^2 - 2bc\cos\alpha \\
b^2 = a^2 + c^2 - 2ac\cos\beta \\
c^2 = a^2 + b^2 - 2ab\cos\gamma
\end{array}\right. .
\end{gather*}
\end{itemize}


\subsection{海伦公式}
设三角形的三边⻓分别为$a$, $b$, $c$.
则对三角形的面积$S$有如下公式:
\begin{gather*}
S = \sqrt{p(p-a)(p-b)(p-c)},
\end{gather*}
其中$p = \frac{1}{2}(a+b+c)$.


\section{一些基础函数以及Point类}
\inputcode{\codecpp}{\codedir/point.cpp}


\section{三角形外心\&点的最小圆覆盖}
\inputcode{\codecpp}{\codedir/functional.cpp}


\section{直线交点\&线段交点}
\inputcode{\codecpp}{\codedir/intersection.cpp}


\section{几何坑点}
\begin{itemize}
\item
在使用反三角函数\texttt{acos()}, \texttt{asin()}时一定要检查输入值是否在函数值域($[-1,1]$)内.

\item
对于输出答案为\texttt{0}的数, 一定要手动判\texttt{0}, 否则可能会输出``\texttt{-0}''导致PE或WA。

\item
尽可能减少Sqrt或除法的使用以提高精度.

\item
浮点数应\texttt{typedef}一个\texttt{DB}类型, 这样可以方便在卡精度时切换\texttt{long double}.

\item
对于需要控制相对误差(而不是绝对误差)的题, 二分/三分时应手动限制查找次数而不是使用\texttt{while(r-l>eps)}, 否则可能由于数值太大引起精度丢失, 最终陷入死循环(cf-1059D).
事实上, 若答案数值过大都应手动限制查找次数.
\end{itemize}
33 changes: 33 additions & 0 deletions chapters/graph.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
\chapter{图论}

\def \codedir{./code/graph/}


\section{Tarjan算法求强连通分量}
\inputcode{\codecpp}{\codedir/tarjan.cpp}


\section{最大流Dinic}
\inputcode{\codecpp}{\codedir/dinic.cpp}


\section{全局最小割(Stoer-Wagner algorithm}
(我不会用orz)
\inputcode{\codecpp}{\codedir/stoer_wagner.cpp}


\section{有向图$k$短路}
\inputcode{\codecpp}{\codedir/kth_path.cpp}


\section{图论相关理论}

\subsection{Hall定理}
考虑二分图$G = \langle V_1, V_2, E \rangle$, 设$|V_1| \leq |V_2|$, 则$G$存在完美匹配当且仅当$V_1$中任意$k \ (k=1,2,\cdots,|V_1|)$个点至少与$V_2$$k$个(不同的)顶点相邻.


\subsection{平面图欧拉公式}
$V$是结点个数, $E$是边的数目, $F$是面(即所谓的联通区域, \textbf{包括外部无穷大平面})的个数, $C$是联通块个数, 则有如下公式:
\begin{gather*}
V-E+F = C+1.
\end{gather*}
Loading

0 comments on commit 0fa6129

Please sign in to comment.