Skip to content

Commit

Permalink
hw12-matching-flow-solution: +template
Browse files Browse the repository at this point in the history
  • Loading branch information
hengxin committed Jun 14, 2021
1 parent b5d8dc1 commit ce7ca42
Show file tree
Hide file tree
Showing 8 changed files with 2,353 additions and 0 deletions.
1 change: 1 addition & 0 deletions 2021/solution/hw12-matching-flow-solution/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# README.md
198 changes: 198 additions & 0 deletions 2021/solution/hw12-matching-flow-solution/hw-preamble.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
% hw-preamble.tex

% geometry for A4 paper
% See https://tex.stackexchange.com/a/119912/23098
\geometry{
left=20.0mm,
top=20.0mm,
bottom=20.0mm,
textwidth=130mm, % main text block
marginparsep=5.0mm, % gutter between main text block and margin notes
marginparwidth=50.0mm % width of margin notes
}

% for colors
\usepackage{xcolor} % usage: \color{red}{text}
% predefined colors
\newcommand{\red}[1]{\textcolor{red}{#1}} % usage: \red{text}
\newcommand{\blue}[1]{\textcolor{blue}{#1}}
\newcommand{\teal}[1]{\textcolor{teal}{#1}}

\usepackage{todonotes}

% heading
\usepackage{sectsty}
\setcounter{secnumdepth}{2}
\allsectionsfont{\centering\huge\rmfamily}

% for Chinese
\usepackage{xeCJK}
\usepackage{zhnumber}
\setCJKmainfont[BoldFont=FandolSong-Bold.otf]{FandolSong-Regular.otf}

% for fonts
\usepackage{fontspec}
\newcommand{\song}{\CJKfamily{song}}
\newcommand{\kai}{\CJKfamily{kai}}

% To fix the ``MakeTextLowerCase'' bug:
% See https://github.com/Tufte-LaTeX/tufte-latex/issues/64#issuecomment-78572017
% Set up the spacing using fontspec features
\renewcommand\allcapsspacing[1]{{\addfontfeature{LetterSpace=15}#1}}
\renewcommand\smallcapsspacing[1]{{\addfontfeature{LetterSpace=10}#1}}

% for url
\usepackage{hyperref}
\hypersetup{colorlinks = true,
linkcolor = teal,
urlcolor = teal,
citecolor = blue,
anchorcolor = blue}

\newcommand{\me}[4]{
\author{
{\bfseries 姓名:}\underline{#1}\hspace{2em}
{\bfseries 学号:}\underline{#2}\hspace{2em}\\[10pt]
{\bfseries 评分:}\underline{#3\hspace{3em}}\hspace{2em}
{\bfseries 评阅:}\underline{#4\hspace{3em}}
}
}

% Please ALWAYS Keep This.
\newcommand{\noplagiarism}{
\begin{center}
\fbox{\begin{tabular}{@{}c@{}}
请独立完成作业,不得抄袭。\\
若得到他人帮助, 请致谢。\\
若参考了其它资料,请给出引用。\\
鼓励讨论,但需独立书写解题过程。
\end{tabular}}
\end{center}
}

% \newcommand{\goal}[1]{
% \begin{center}{\fcolorbox{blue}{yellow!60}{\parbox{0.50\textwidth}{\large
% \begin{itemize}
% \item 体会``思维的乐趣''
% \item 初步了解递归与数学归纳法
% \item 初步接触算法概念与问题下界概念
% \end{itemize}}}}
% \end{center}
% }

% Each hw consists of four parts:
\newcommand{\beginrequired}{\hspace{5em}\section{作业 (必做部分)}}
\newcommand{\beginoptional}{\section{作业 (选做部分)}}
\newcommand{\beginot}{\section{Open Topics}}
\newcommand{\begincorrection}{\section{订正}}
\newcommand{\beginfb}{\section{反馈}}

% for math
\usepackage{amsmath, mathtools, amsfonts, amssymb}
\newcommand{\set}[1]{\{#1\}}
\newcommand{\ps}[1]{\mathcal{P}(#1)}

% define theorem-like environments
\usepackage[amsmath, thmmarks]{ntheorem}

\theoremstyle{break}
\theorempreskip{2.0\topsep}
\theorembodyfont{\song}
\theoremseparator{}
\newtheorem{problem}{题目}[subsection]
\renewcommand{\theproblem}{\arabic{problem}}
\newtheorem{definition}{定义}[subsection]
\renewcommand{\thedefinition}{\arabic{definition}}
\newtheorem{theorem}{定理}[subsection]
\renewcommand{\thetheorem}{\arabic{theorem}}
\newtheorem{ot}{Open Topics}

\theorempreskip{3.0\topsep}
\theoremheaderfont{\kai\bfseries}
\theoremseparator{:}
\theorempostwork{\bigskip\hrule}
\newtheorem*{solution}{解答}
\theorempostwork{\bigskip\hrule}
\newtheorem*{revision}{订正}

\theoremstyle{plain}
\newtheorem*{cause}{错因分析}
\newtheorem*{remark}{注}

\theoremstyle{break}
\theorempostwork{\bigskip\hrule}
\theoremsymbol{\ensuremath{\Box}}
\newtheorem*{proof}{证明}

% \newcommand{\ot}{\blue{\bf [OT]}}

% for figs
\renewcommand\figurename{图}
\renewcommand\tablename{表}

% for fig without caption: #1: width/size; #2: fig file
\newcommand{\fig}[2]{
\begin{figure}[htbp]
\centering
\includegraphics[#1]{#2}
\end{figure}
}
% for fig with caption: #1: width/size; #2: fig file; #3: caption
\newcommand{\figcap}[3]{
\begin{figure}[htbp]
\centering
\includegraphics[#1]{#2}
\caption{#3}
\end{figure}
}
% for fig with both caption and label: #1: width/size; #2: fig file; #3: caption; #4: label
\newcommand{\figcaplbl}[4]{
\begin{figure}[htbp]
\centering
\includegraphics[#1]{#2}
\caption{#3}
\label{#4}
\end{figure}
}
% for margin fig without caption: #1: width/size; #2: fig file
\newcommand{\mfig}[2]{
\begin{marginfigure}
\centering
\includegraphics[#1]{#2}
\end{marginfigure}
}
% for margin fig with caption: #1: width/size; #2: fig file; #3: caption
\newcommand{\mfigcap}[3]{
\begin{marginfigure}
\centering
\includegraphics[#1]{#2}
\caption{#3}
\end{marginfigure}
}

\usepackage{fancyvrb}

% for algorithms
\usepackage[]{algorithm}
\usepackage[]{algpseudocode} % noend
% See [Adjust the indentation whithin the algorithmicx-package when a line is broken](https://tex.stackexchange.com/a/68540/23098)
\newcommand{\algparbox}[1]{\parbox[t]{\dimexpr\linewidth-\algorithmicindent}{#1\strut}}
\newcommand{\hStatex}[0]{\vspace{5pt}}
\makeatletter
\newlength{\trianglerightwidth}
\settowidth{\trianglerightwidth}{$\triangleright$~}
\algnewcommand{\LineComment}[1]{\Statex \hskip\ALG@thistlm \(\triangleright\) #1}
\algnewcommand{\LineCommentCont}[1]{\Statex \hskip\ALG@thistlm%
\parbox[t]{\dimexpr\linewidth-\ALG@thistlm}{\hangindent=\trianglerightwidth \hangafter=1 \strut$\triangleright$ #1\strut}}
\makeatother

% for footnote/marginnote
% see https://tex.stackexchange.com/a/133265/23098
\usepackage{tikz}
\newcommand{\circled}[1]{%
\tikz[baseline=(char.base)]
\node [draw, circle, inner sep = 0.5pt, font = \tiny, minimum size = 8pt] (char) {#1};
}
\renewcommand\thefootnote{\protect\circled{\arabic{footnote}}}

\newcommand{\score}[1]{{\bf [#1 分]}}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
% hw12-matching-flow-solution.tex

% !TEX program = xelatex
%%%%%%%%%%%%%%%%%%%%
% see http://mirrors.concertpass.com/tex-archive/macros/latex/contrib/tufte-latex/sample-handout.pdf
% for how to use tufte-handout
\documentclass[a4paper, justified]{tufte-handout}

\input{hw-preamble} % feel free to modify this file if you understand LaTeX well
%%%%%%%%%%%%%%%%%%%%
\title{12. 图论: 匹配与网络流 (12-matching-flow)}
\me{魏恒峰}{hfwei@nju.edu.cn}{}{}
\date{2021年05月28日 发布作业 \\ 2021年06月xx日 发布答案}
%%%%%%%%%%%%%%%%%%%%
\begin{document}
\maketitle
%%%%%%%%%%%%%%%%%%%%
\noplagiarism % PLEASE DON'T DELETE THIS LINE!
%%%%%%%%%%%%%%%%%%%%
\begin{abstract}
% \mfigcap{width = 0.85\textwidth}{figs/George-Boole}{George Boole}
% \begin{center}{\fcolorbox{blue}{yellow!60}{\parbox{0.65\textwidth}{\large
% \begin{itemize}
% \item
% \end{itemize}}}}
% \end{center}
\end{abstract}
%%%%%%%%%%%%%%%%%%%%
\beginrequired
%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%
\begin{problem}[\score{5 = 2 + 3} $\star\star$]
$G = (X, Y, E)$ 是一个 $k$-正则 ($k > 0$) 二部图。
请证明:
\begin{enumerate}[(1)]
\item $|X| = |Y|$;
\item $G$ 有一个 $X$-完美匹配。
\end{enumerate}
\end{problem}

\begin{proof}
\end{proof}
%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%
\begin{problem}[\score{5} $\star\star\star$]
$G = (V, E)$ 是含有 $2n$ 个顶点的简单图,且 $\delta(G) \ge n + 1$\\
请证明: $G$ 有完美匹配~\footnote{对于任意图, 完美匹配是 cover 了所有顶点的匹配。}。
(提示: 考虑使用图论第一讲中的定理。)
\end{problem}

\begin{proof}
\end{proof}
%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%
\begin{problem}[\score{5} $\star\star\star\star$]
请证明: 每个二部图 $G$ 都有一个大小 $\ge e(G)/\Delta(G)$ 的匹配~\footnote{$e(G)$表示$G$的边数。}。
(提示: 使用 K\"{o}nig-Egerv\'{a}ry 定理。)
\end{problem}

\begin{proof}
\end{proof}
%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%
\begin{problem}[\score{5} $\star\star$]
$Y$ 为集合,
$\mathcal{A} = \set{A_{1}, \dots, A_{m}}$
为包含 $m$ 个集合的集合, 其中 $A_{i} \subseteq Y$ (对 $1 \le i \le m$)。
$\mathcal{A}$ 的相异代表系 (System of Distinct Representatives; SDR)
$Y$$m$ 个不同元素 $a_{1}, \dots, a_{m}$ 构成的集合,
其中 $a_{i} \in A_{i}$ (对 $1 \le i \le m$)。

\noindent 请证明: $\mathcal{A}$ 有 SDR 当且仅当
\[
\forall S \subseteq \set{1, \dots, m}.\;
\big\lvert \bigcup_{i \in S} A_{i} \big\rvert \ge |S|.
\]
\end{problem}

\begin{proof}
\end{proof}
%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%
% 如果没有需要订正的题目,可以把这部分删掉
\begincorrection
%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%
% 如果没有反馈,可以把这部分删掉
\beginfb

你可以写 (也可以发邮件或者使用``教学立方'')
\begin{itemize}
\item 对课程及教师的建议与意见
\item 教材中不理解的内容
\item 希望深入了解的内容
\item $\cdots$
\end{itemize}
%%%%%%%%%%%%%%%%%%%%
\end{document}
80 changes: 80 additions & 0 deletions 2021/solution/hw12-matching-flow-solution/tufte-book.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
\NeedsTeXFormat{LaTeX2e}[1994/06/01]

\ProvidesClass{tufte-book}[2009/12/11 v3.5.0 Tufte-book class]

%%
% Declare we're tufte-book
\newcommand{\@tufte@class}{book}% the base LaTeX class (defaults to the article/handout style)
\newcommand{\@tufte@pkgname}{tufte-book}% the name of the package (defaults to tufte-handout)

%%
% Load the common style elements
\input{tufte-common.def}


%%
% Set up any book-specific stuff now

%%
% The front matter in Tufte's /Beautiful Evidence/ contains everything up
% to the opening page of Chapter 1. The running heads, when they appear,
% contain only the (arabic) page number in the outside corner.
%\newif\if@mainmatter \@mainmattertrue
\renewcommand\frontmatter{%
\cleardoublepage%
\@mainmatterfalse%
\pagenumbering{arabic}%
%\pagestyle{plain}%
\fancyhf{}%
\ifthenelse{\boolean{@tufte@twoside}}%
{\fancyhead[LE,RO]{\thepage}}%
{\fancyhead[RE,RO]{\thepage}}%
}


%%
% The main matter in Tufte's /Beautiful Evidence/ doesn't restart the page
% numbering---it continues where it left off in the front matter.
\renewcommand\mainmatter{%
\cleardoublepage%
\@mainmattertrue%
\fancyhf{}%
\ifthenelse{\boolean{@tufte@twoside}}%
{% two-side
\renewcommand{\chaptermark}[1]{\markboth{##1}{}}%
\fancyhead[LE]{\thepage\quad\smallcaps{\newlinetospace{\plaintitle}}}% book title
\fancyhead[RO]{\smallcaps{\newlinetospace{\leftmark}}\quad\thepage}% chapter title
}%
{% one-side
\fancyhead[RE,RO]{\smallcaps{\newlinetospace{\plaintitle}}\quad\thepage}% book title
}%
}


%%
% The back matter contains appendices, indices, glossaries, endnotes,
% biliographies, list of contributors, illustration credits, etc.
\renewcommand\backmatter{%
\if@openright%
\cleardoublepage%
\else%
\clearpage%
\fi%
\@mainmatterfalse%
}

%%
% Only show the chapter titles in the table of contents
\setcounter{tocdepth}{0}

%%
% If there is a `tufte-book-local.sty' file, load it.

\IfFileExists{tufte-book-local.tex}
{\input{tufte-book-local}
\TufteInfoNL{Loading tufte-book-local.tex}}
{}

%%
% End of file
\endinput
Loading

0 comments on commit ce7ca42

Please sign in to comment.