2023-01-13 10:17:11 -08:00

132 lines
1.9 KiB
TeX

\section{Crosses}
You are given an $n \times n$ grid. Some of its squares are white, some are gray. Your goal is to place $n$ crosses on white cells so that each row and each column contains exactly one cross.
\vspace{2ex}
Here is an example of such a grid, including a possible solution.
\newcommand{\bx}[2]{
\draw[
line width = 1.5mm
]
(#1 + 0.3, #2 + 0.3) -- (#1 + 0.7, #2 + 0.7)
(#1 + 0.7, #2 + 0.3) -- (#1 + 0.3, #2 + 0.7);
}
\newcommand{\dk}[2]{
\draw[
line width = 0mm,
fill = gray
]
(#1, #2) --
(#1 + 1, #2) --
(#1 + 1, #2 + 1) --
(#1, #2 + 1);
}
\begin{center}
\begin{tikzpicture}[
scale = 0.8
]
% Dark squares
\dk{0}{2}
\dk{1}{0}
\dk{1}{1}
\dk{1}{2}
\dk{1}{4}
\dk{2}{2}
\dk{2}{4}
\dk{3}{0}
\dk{3}{1}
\dk{3}{3}
\dk{3}{4}
\dk{4}{3}
\dk{4}{1}
% Base grid
\foreach \x in {0,...,5} {
\draw[line width = 0.4mm]
(0, \x) -- (5, \x)
(\x, 0) -- (\x, 5);
}
% X marks
\bx{0}{4}
\bx{1}{3}
\bx{2}{1}
\bx{3}{2}
\bx{4}{0}
\end{tikzpicture}
\end{center}
\problem{}
Find a solution for the following grid.
\begin{center}
\begin{tikzpicture}[
scale = 1
]
% Dark squares
\dk{0}{2}
\dk{0}{3}
\dk{0}{6}
\dk{0}{7}
\dk{1}{0}
\dk{1}{1}
\dk{1}{4}
\dk{1}{5}
\dk{1}{6}
\dk{1}{7}
\dk{2}{0}
\dk{2}{1}
\dk{2}{3}
\dk{2}{4}
\dk{2}{5}
\dk{2}{6}
\dk{2}{7}
\dk{3}{1}
\dk{3}{2}
\dk{3}{3}
\dk{3}{4}
\dk{3}{5}
\dk{3}{6}
\dk{4}{0}
\dk{4}{1}
\dk{4}{2}
\dk{4}{3}
\dk{4}{6}
\dk{5}{1}
\dk{5}{4}
\dk{5}{5}
\dk{5}{6}
\dk{6}{0}
\dk{6}{1}
\dk{6}{2}
\dk{6}{3}
\dk{6}{4}
\dk{6}{5}
\dk{7}{0}
\dk{7}{4}
\dk{7}{6}
\dk{7}{7}
% Base grid
\foreach \x in {0,...,8} {
\draw[line width = 0.4mm]
(0, \x) -- (8, \x)
(\x, 0) -- (\x, 8);
}
\end{tikzpicture}
\end{center}
\pagebreak
\problem{}
Turn this into a network flow problem that can be solved with the Ford-Fulkerson algorithm.
\vfill
\pagebreak