From bc086468072401aec9e63ee3c78fdc21b1473cf7 Mon Sep 17 00:00:00 2001 From: ouuan Date: Sat, 24 Aug 2019 13:39:58 +0800 Subject: [PATCH] Update htc.md --- docs/intro/htc.md | 74 +++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/docs/intro/htc.md b/docs/intro/htc.md index 8f7ee906..b15a7c6b 100644 --- a/docs/intro/htc.md +++ b/docs/intro/htc.md @@ -159,48 +159,42 @@ LaTeX 作为公式排版的首选,我们应当正确地使用它。因此对 伪码具体格式没有严格要求,请参考算法导论或学术论文,注意不要写成 Python。 -Wiki 内使用 LaTeX 书写伪码,缩进使用 `$\qquad$` ,文字描述使用 `$\text$` ,关键字使用 `$\textbf$` ,赋值使用 `$\gets$` 。 - - $\begin{aligned}\textbf{Input.}&\text{ The edges of the graph }e\text{, where each element in }e\text{ is }(u, v, w)\\&\text{ denoting that there is an edge between }u\text{ and }v\text{ weighted }w\text{.}\end{aligned}$ - - $\textbf{Output.}\text{ The edges of the MST of the input graph.}$ - - $\textbf{Method.}$ - - $result \gets \varnothing$ - - $\text{sort }e\text{ into nondecreasing order by weight }w$ - - $\textbf{for}\text{ each }(u, v, w)\text{ in the sorted }e$ - - $\qquad\textbf{if }u\text{ and }v\text{ are not connected in the union-find set}$ - - $\qquad\qquad\text{connect }u\text{ and }v\text{ in the union-find set}$ - - $\qquad\qquad result \gets result\ \bigcup\ \{(u, v, w)\}$ - - $\textbf{return }result$ +Wiki 内使用 LaTeX 书写伪码,整体处于 array 环境中,缩进使用 `$\qquad$` ,文字描述使用 `$\text$` ,关键字使用 `$\textbf$` ,赋值使用 `$\gets$` 。 + +参考示例: + +$$ +\begin{array}{ll} +1 & \textbf{Input. } \text{The edges of the graph } e , \text{ where each element in } e \text{ is } (u, v, w) \\ + & \text{ denoting that there is an edge between } u \text{ and } v \text{ weighted } w . \\ +2 & \textbf{Output. } \text{The edges of the MST of the input graph}.\\ +3 & \textbf{Method. } \\ +4 & result \gets \varnothing \\ +5 & \text{sort } e \text{ into nondecreasing order by weight } w \\ +6 & \textbf{for} \text{ each } (u, v, w) \text{ in the sorted } e \\ +7 & \qquad \textbf{if } u \text{ and } v \text{ are not connected in the union-find set } \\ +8 & \qquad\qquad \text{connect } u \text{ and } v \text{ in the union-find set} \\ +9 & \qquad\qquad result \gets result\;\bigcup\ \{(u, v, w)\} \\ +10 & \textbf{return } result +\end{array} +$$ ```latex - $\begin{aligned}\textbf{Input.}&\text{ The edges of the graph }e\text{, where each element in }e\text{ is }(u, v, w)\\&\text{ denoting that there is an edge between }u\text{ and }v\text{ weighted }w\text{.}\end{aligned}$ - - $\textbf{Output.}\text{ The edges of the MST of the input graph.}$ - - $\textbf{Method.}$ - - $result \gets \varnothing$ - - $\text{sort }e\text{ into nondecreasing order by weight }w$ - - $\textbf{for}\text{ each }(u, v, w)\text{ in the sorted }e$ - - $\qquad\textbf{if }u\text{ and }v\text{ are not connected in the union-find set}$ - - $\qquad\qquad\text{connect }u\text{ and }v\text{ in the union-find set}$ - - $\qquad\qquad result \gets result\ \bigcup\ \{(u, v, w)\}$ - - $\textbf{return }result$ +$$ +\begin{array}{ll} +1 & \textbf{Input. } \text{The edges of the graph } e , \text{ where each element in } e \text{ is } (u, v, w) \\ + & \text{ denoting that there is an edge between } u \text{ and } v \text{ weighted } w . \\ +2 & \textbf{Output. } \text{The edges of the MST of the input graph}.\\ +3 & \textbf{Method. } \\ +4 & result \gets \varnothing \\ +5 & \text{sort } e \text{ into nondecreasing order by weight } w \\ +6 & \textbf{for} \text{ each } (u, v, w) \text{ in the sorted } e \\ +7 & \qquad \textbf{if } u \text{ and } v \text{ are not connected in the union-find set } \\ +8 & \qquad\qquad \text{connect } u \text{ and } v \text{ in the union-find set} \\ +9 & \qquad\qquad result \gets result\;\bigcup\ \{(u, v, w)\} \\ +10 & \textbf{return } result +\end{array} +$$ ``` ## 图解 -- 2.11.0